2019年11月30日 星期六
2019年11月15日 星期五
變更組裝,加入超音波測距模組
https://hackmd.io/@yoyostudy/ByGowUKIO
先讓它動起來:
int M1 = 10; //enable right whell
int E1 =12; //high;forward
int M2 =11; //enable left whell
int E2 = 13; //high:forward
int BUZZER =4;
int TRIGGER_OUT=7;
int ECHO_IN=8;
long ultrasonic_rangefinder()
{
digitalWrite(TRIGGER_OUT, HIGH); // 給 Trig 高電位,持續 10微秒
delayMicroseconds(10);
digitalWrite(TRIGGER_OUT, LOW);
long duration = pulseIn(ECHO_IN, HIGH);
long cm = (duration/2) / 29.1;
return(cm);
}
void motor_forward()
{
digitalWrite(M1,HIGH);
digitalWrite(E1,HIGH);
digitalWrite(M2,HIGH);
digitalWrite(E2,HIGH);
}
void motor_stop()
{
digitalWrite(M1,LOW);
digitalWrite(M2,LOW);
}
void motor_backward()
{
digitalWrite(M1,HIGH);
digitalWrite(E1,LOW);
digitalWrite(M2,HIGH);
digitalWrite(E2,LOW);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//initial motor
pinMode(M1, OUTPUT);
pinMode(E1, OUTPUT);
pinMode(M2, OUTPUT);
pinMode(E2, OUTPUT);
//initial buzzer
pinMode(BUZZER,OUTPUT);
//initial ultrasonic rangefinder
pinMode(TRIGGER_OUT,OUTPUT);
pinMode(ECHO_IN,INPUT);
//motor stop
digitalWrite(M1,LOW);
digitalWrite(M2,LOW);
//buzzer off
digitalWrite(BUZZER,LOW);
//ultrasonic rangefinder off
digitalWrite(TRIGGER_OUT,LOW);
}
void loop() {
// put your main code here, to run repeatedly:
long dist,dist1,dist2;
delay(50);
dist1=ultrasonic_rangefinder();
dist2=ultrasonic_rangefinder();
dist=(dist1+dist2)/2;
Serial.print(dist);
Serial.print(" ");
if(dist>50)
{
motor_forward();
digitalWrite(BUZZER,LOW);
}
else if(dist<20)
{
motor_backward();
digitalWrite(BUZZER,HIGH);
}
}
成功....YA!! YA!!
跑得好慢.....Zzzz
2019年11月1日 星期五
組裝
2019年9月25日 星期三
2019年9月17日 星期二
[linux]shell script 教學
不錯的文章
http://www.runoob.com/linux/linux-shell.html
linux echo命令的-n、-e两个参数
http://blog.sina.com.cn/s/blog_4da051a6010184uk.html
let命令
http://mirror.sars.tw/Bash_Shell_by_ols3/c860.html
python 調用shell python shell 間變量傳遞
http://www.runoob.com/linux/linux-shell.html
linux echo命令的-n、-e两个参数
http://blog.sina.com.cn/s/blog_4da051a6010184uk.html
let命令
https://man.linuxde.net/let
http://mirror.sars.tw/Bash_Shell_by_ols3/c860.html
python 調用shell python shell 間變量傳遞
https://blog.csdn.net/ysdaniel/article/details/7970978 -->怪怪的!!
How to import python variable in shell script
How to import python variable in shell script
https://unix.stackexchange.com/questions/316895/how-to-import-python-variable-in-shell-script
2019年8月29日 星期四
[raspberry]USB音效卡
不知為什麼,系統開機的audio 都無法預設成 usb audio.......@$%
不錯的文張
Using a USB Audio Device With a Raspberry Pi
不錯的文張
Using a USB Audio Device With a Raspberry Pi
https://computers.tutsplus.com/articles/using-a-usb-audio-device-with-a-raspberry-pi--mac-55876
Using a USB Audio Device with the Raspberry Pi
https://www.raspberrypi-spy.co.uk/2019/06/using-a-usb-audio-device-with-the-raspberry-pi/
Raspberry Pi 筆記(11):音效設定與播放器
Using a USB Audio Device with the Raspberry Pi
https://www.raspberrypi-spy.co.uk/2019/06/using-a-usb-audio-device-with-the-raspberry-pi/
Raspberry Pi 筆記(11):音效設定與播放器
https://atceiling.blogspot.com/2014/02/raspberry-pi.html
USB Audio Cards with a Raspberry Pihttps://learn.adafruit.com/usb-audio-cards-with-a-raspberry-pi/instructions
USB Audio Cards with a Raspberry Pihttps://learn.adafruit.com/usb-audio-cards-with-a-raspberry-pi/instructions
2019年8月22日 星期四
[raspberry] python操作 GPIO
不錯的文張
讓你的 Raspberry Pi 透過 GPIO 閃爍 LED 燈
讓你的 Raspberry Pi 透過 GPIO 閃爍 LED 燈
https://coldnew.github.io/f7349436/
訂閱:
文章 (Atom)



