Tadao Iida
/
ServoCheck
エレキジャック Web版 マイコン・カーを製作してみよう<8>で紹介したサーボを制御するプログラムです。http://www.eleki-jack.com/arm/2012/05/8.html
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 DigitalIn left(p19); 00005 DigitalIn right(p20); 00006 PwmOut servo(p21); 00007 TextLCD lcd(p24, p26, p27, p28, p29, p30); 00008 00009 int main() { 00010 lcd.cls( ); 00011 servo.period(0.04); 00012 while(1) { 00013 lcd.locate(0,0); 00014 if ( left == 1 ){ 00015 lcd.printf("Left "); 00016 servo.pulsewidth_us(1200); 00017 }else if ( right == 1 ){ 00018 lcd.printf("Right "); 00019 servo.pulsewidth_us(1800); 00020 }else{ 00021 lcd.printf(" "); 00022 servo.pulsewidth_us(1500); 00023 } 00024 } 00025 }
Generated on Fri Jul 22 2022 04:24:33 by 1.7.2