Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 3:59ace4ccc91d, committed 2022-09-12
- Comitter:
- phianel
- Date:
- Mon Sep 12 08:55:17 2022 +0000
- Parent:
- 2:507b31207449
- Child:
- 4:d91aa84213fd
- Commit message:
- air
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Sep 06 06:07:56 2022 +0000
+++ b/main.cpp Mon Sep 12 08:55:17 2022 +0000
@@ -5,6 +5,12 @@
#define INT_TIME 0.001
#define INT_TIME_MS INT_TIME*1000
+PwmOut lfP(p21);//左前 出力
+PwmOut rfP(p22);//右前 出力
+PwmOut lbP(p23);//左後 出力
+PwmOut rbP(p24);//右後 出力
+DigitalOut air(p25);//エアシリンダーのつもり
+
Serial pc(USBTX, USBRX,115200);
Controller con(p9,p10,115200); //TXpin, RXpin, baudrateを設定
//Controller con(p13,p14,115200); //TXpin, RXpin, baudrateを設定
@@ -51,17 +57,44 @@
if(con.available())
{
int buttonState = con.getButtonState();
- uint8_t joyRx = con.readJoyRXbyte();
uint8_t joyRy = con.readJoyRYbyte();
uint8_t joyLx = con.readJoyLXbyte();
uint8_t joyLy = con.readJoyLYbyte();
pc.printf("%u\t", buttonState);
- pc.printf("%u\t", joyRx);
pc.printf("%u\t", joyRy);
pc.printf("%u\t", joyLx);
- pc.printf("%u\r\n", joyLy);
+ pc.printf("%u\r", joyLy);
+
+ switch(buttonState)
+ {
+ case 8:
+ air.write(1);
+ break;
+ default:
+ air.write(0);
+ break;
+ }
+ double LF=0;
+ double RF=0;
+ double LB=0;
+ double RB=0;
+
+ LF=joyLx-joyLy-joyRy+128;//上と左が正 下と右が負 Yがスティック左右方向 Xがスティック上下方向
+ RF=-joyLx-joyLy-joyRy+384;
+ LB=joyLx+joyLy-joyRy-128;
+ RB=-joyLx+joyLy-joyRy+128;
+
+ lfP.write(LF);
+ rfP.write(RF);
+ lbP.write(LB);
+ rbP.write(RB);
+
+ pc.printf("%lf\t", LF);
+ pc.printf("%lf\t", RF);
+ pc.printf("%lf\t", LB);
+ pc.printf("%lf\r\n", RB);
//led_red.write(1);
//pin_emergency.write(1); //非常停止を解除する
}