Compare commits

..

No commits in common. "aa1ce997cd45172782e5c540d1a36a45eaa08ee7" and "bf17e4b02eb9060159adb5676cb446bb62b272c7" have entirely different histories.

3 changed files with 2 additions and 226 deletions

View file

@ -7,7 +7,7 @@ void setup() {
servo1.attach(9);
servo2.attach(10);
Serial.begin(9600);
Serial.println("format : [0-180][ab]");
Serial.print("format : [0-180][ab]");
}
void loop() {
@ -21,14 +21,10 @@ void loop() {
v = v * 10 + ch - '0';
break;
case 'a':
Serial.print("Servo(9) :");
Serial.println(v);
servo1.write(v);
v = 0;
break;
case 'b':
Serial.print("Servo(10):");
Serial.println(v);
servo2.write(v);
v = 0;
break;

View file

@ -1,123 +0,0 @@
#include <Servo.h>
// Servo : SC-1267SG
unsigned int steeringServoCenter = 1820; //us
unsigned int steeringServoMin = (steeringServoCenter-780); //us
unsigned int steeringServoMax = (steeringServoCenter+780); //us
// Servo : SC-0352
unsigned int lanceServoCenter = 1560; //us
unsigned int lanceServoMin = (lanceServoCenter-780); //us
unsigned int lanceServoMax = (lanceServoCenter+780); //us
unsigned char rotPin = 2;
unsigned char numSensors = 8;
unsigned char sensorPin[] = {19,18,17,16,15,14,13,12}; //右端から順番に左端へ
unsigned char steeringServoPin = 9;
unsigned char lanceServoPin = 10;
volatile unsigned long distance = 0;
Servo lanceServo;
Servo steeringServo;
/* ステアリングを中央からa[度]だけ動かす
<- - 0 + ->
||
||
[]---{}---[]
/ .\
*/
int steering(int a){
steeringServo.write(90 + a);
return (steeringServo.read() - 90);
}
/* ランスを中央からa[度]だけ動かす
<- - 0 + ->
/ .\
/ | \
[]+--{}--+[]
*/
int lance(int a){
lanceServo.write(90 - a);
return (90 - a);
}
/* センサーのアレイの初期化 */
void sensorInit(){
for(int i=0; i<numSensors; i++){
pinMode(sensorPin[i], INPUT);
}
}
/* エンコーダーの割り込み処理 */
void rot(){
distance++;
}
void setup() {
steeringServo.attach(steeringServoPin, steeringServoMin, steeringServoMax);
lanceServo.attach(lanceServoPin, lanceServoMin, lanceServoMax);
steering(0);
lance(0);
pinMode(rotPin, INPUT);
attachInterrupt(0, rot, RISING);
Serial.begin(9600);
Serial.println("format : [+-][0-180][hl]");
}
void loop() {
static int i = 0;
i++;
if(i>100){
i = 0;
Serial.print(distance);
Serial.print('\t');
for(int i=0; i<numSensors; i++){
Serial.print(digitalRead(sensorPin[i]));
}
Serial.println();
}
static int v = 0;
static int s = 1;
if ( Serial.available() ) {
char ch = Serial.read();
switch(ch) {
case '-':
s = -1;
break;
case '0'...'9':
v = v * 10 + ch - '0';
break;
case 'l':
v = s*v;
Serial.print("lance :");
Serial.println(v);
lance(v);
v = 0;
s = 1;
break;
case 'h':
v = s*v;
Serial.print("steering :");
Serial.println(v);
steering(v);
v = 0;
s = 1;
break;
case 'c':
Serial.println("clear");
distance = 0;
v = 0;
s = 1;
break;
}
}
delay(1);
}

View file

@ -3,7 +3,7 @@
#fi
#export LANG
PATH="~/Documents/bin:$PATH"
PATH="~/bin:$PATH"
PS1='\[\e[1;32m\]\D{%F %T}\[\e[0m\] \[\e[1;34m\]\w\[\e[0;1m\]
\$ \[\e[0m\]'
@ -34,109 +34,12 @@ complete -c man sudo
set -o noclobber
alias base64=gbase64
alias basename=gbasename
alias cat=gcat
alias chgrp=gchgrp
alias chmod=gchmod
alias chown=gchown
alias chroot=gchroot
alias cksum=gcksum
alias comm=gcomm
alias cp=gcp
alias csplit=gcsplit
alias cut=gcut
alias date=gdate
alias dd=gdd
alias df=gdf
alias dir=gdir
alias dircolors=gdircolors
alias dirname=gdirname
alias du=gdu
alias echo=gecho
alias env=genv
alias expand=gexpand
alias expr=gexpr
alias factor=gfactor
alias false=gfalse
alias fmt=gfmt
alias fold=gfold
alias groups=ggroups
alias head=ghead
alias hostid=ghostid
alias hostname=ghostname
alias id=gid
alias install=ginstall
alias join=gjoin
alias kill=gkill
alias link=glink
alias ln=gln
alias logname=glogname
alias ls='gls -F'
alias md5sum=gmd5sum
alias mkdir=gmkdir
alias mkfifo=gmkfifo
alias mknod=gmknod
alias mv=gmv
alias nice=gnice
alias nl=gnl
alias nohup=gnohup
alias od=god
alias paste=gpaste
alias pathchk=gpathchk
alias pinky=gpinky
alias pr=gpr
alias printenv=gprintenv
alias printf=gprintf
alias ptx=gptx
alias pwd=gpwd
alias readlink=greadlink
alias rm=grm
alias rmdir=grmdir
alias seq=gseq
alias sha1sum=gsha1sum
alias sha224sum=gsha224sum
alias sha256sum=gsha256sum
alias sha384sum=gsha384sum
alias sha512sum=gsha512sum
alias shred=gshred
alias shuf=gshuf
alias sleep=gsleep
alias sort=gsort
alias split=gsplit
alias stat=gstat
alias stty=gstty
alias su=gsu
alias sum=gsum
alias sync=gsync
alias tac=gtac
alias tail=gtail
alias tee=gtee
alias test=gtest
alias touch=gtouch
alias tr=gtr
alias true=gtrue
alias tsort=gtsort
alias tty=gtty
alias uname=guname
alias unexpand=gunexpand
alias uniq=guniq
alias unlink=gunlink
alias uptime=guptime
alias users=gusers
alias vdir=gvdir
alias wc=gwc
alias who=gwho
alias whoami=gwhoami
alias yes=gyes
alias ls='ls -G'
alias l='ls -alh'
alias cp='cp -iv'
alias mv='mv -iv'
alias ln='ln -iv'
alias rm='rm -iv'
alias mkdir='mkdir -v'
alias grep='grep --color'
alias egrep='egrep --color'
alias bc='bc -l'