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.
Dependencies: ADXL345_I2C Control_Yokutan_CANver1 mbed
Fork of Control_Yokutan_CAN_ver2 by
Revision 1:9cc932a16d17, committed 2016-02-13
- Comitter:
- taurin
- Date:
- Sat Feb 13 11:35:50 2016 +0000
- Parent:
- 0:e052602db102
- Child:
- 2:7fcb4f970a02
- Commit message:
- 2/13
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Jan 29 13:38:29 2016 +0000
+++ b/main.cpp Sat Feb 13 11:35:50 2016 +0000
@@ -15,9 +15,10 @@
INA226 VCmonitor(ina226_i2c);
PwmOut servo1(p21);
PwmOut servo2(p22);
+DigitalOut led1(LED1);
char toSendDatas[TO_SEND_DATAS_NUM];
-char controlValues[CONTROL_VALUES_NUM];
+char controlValues[CONTROL_VALUES_NUM];//0:eruruon,1:drug
int counter = 0;
int eruron_deg = 0;
@@ -85,6 +86,7 @@
for(int i = 0; i < recmsg.len; i++){
controlValues[i] = recmsg.data[i];
}
+ led1 = !led1;
}
}
@@ -107,14 +109,25 @@
pc.printf("resend suc\n\r");
}
-void
+double calcPulse(int deg){
+ return (0.00093+(deg/180.0)*(0.00235-0.00077));
+}
+
+void WriteServo(){
+ if(controlValues[0]){
+ servo1.pulsewidth(calcPulse(90));
+ }
+ else{
+ servo1.pulsewidth(calcPulse(45));
+ }
+}
int main(){
init();
while(1){
receiveDatas();
updateDatas();
- //WriteServo();
+ WriteServo();
toString();
sendDatas();
wait_ms(WAIT_LOOP_TIME_MS);
