code for sterring wheel interface
Dependencies: MBC002-DigitalIn
Diff: main.cpp
- Revision:
- 9:33d8b36e81d4
- Parent:
- 8:f8a9b7dbf399
- Child:
- 10:4ff4a376a6fd
diff -r f8a9b7dbf399 -r 33d8b36e81d4 main.cpp --- a/main.cpp Thu Jun 28 13:40:21 2018 +0000 +++ b/main.cpp Fri Jun 29 12:25:39 2018 +0000 @@ -5,8 +5,11 @@ //int ARRAY_SOURCE[] = {342,171,21,64,21,21,21,21,21,64,21,64,21,64,21,21,21,64,21,21,21,64,21,64,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,64,21,21,21,64,21,21,21,21,21,21,21,64,21,64,21,21,21,64,21,21,21,64,21,64,21,64,21,1}; //int ARRAY_TEL[] = {342,171,21,64,21,21,21,21,21,64,21,64,21,64,21,21,21,64,21,21,21,64,21,64,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,64,21,21,21,64,21,21,21,21,21,21,21,64,21,64,21,21,21,64,21,21,21,64,21,64,21,64,21,1}; -int ARRAY_SOURCE[] = {9000,4500,560,1690,560,560,560,560,560,1690,560,1690,560,1690,560,560,560,1690,560,560,560,1690,560,1690,560,560,560,560,560,560,560,1690,560,560,560,560,560,560,560,1690,560,560,560,1690,560,560,560,560,560,560,560,1690,560,1690,560,560,560,1690,560,560,560,1690,560,1690,560,1690,560,26}; -int ARRAY_TEL[] = {9000,4500,560,1690,560,560,560,560,560,1690,560,1690,560,1690,560,560,560,1690,560,560,560,1690,560,1690,560,560,560,560,560,560,560,1690,560,560,560,560,560,560,560,1690,560,560,560,1690,560,560,560,560,560,560,560,1690,560,1690,560,560,560,1690,560,560,560,1690,560,1690,560,1690,560,26}; +//int ARRAY_SOURCE[] = {9000,4500,560,1690,560,560,560,560,560,1690,560,1690,560,1690,560,560,560,1690,560,560,560,1690,560,1690,560,560,560,560,560,560,560,1690,560,560,560,560,560,560,560,1690,560,560,560,1690,560,560,560,560,560,560,560,1690,560,1690,560,560,560,1690,560,560,560,1690,560,1690,560,1690,560,26}; +//int ARRAY_TEL[] = {9000,4500,560,1690,560,560,560,560,560,1690,560,1690,560,1690,560,560,560,1690,560,560,560,1690,560,1690,560,560,560,560,560,560,560,1690,560,560,560,560,560,560,560,1690,560,560,560,1690,560,560,560,560,560,560,560,1690,560,1690,560,560,560,1690,560,560,560,1690,560,1690,560,1690,560,26}; + +int ARRAY_SOURCE[] = {4421,4447,560,1690,560,1690,560,1690,560,560,560,560,560,560,560,560,560,560,560,1690,560,1690,560,1690,560,560,560,560,560,560,560,560,560,560,560,1690,560,1690,560,1690,560,560,560,560,560,560,560,560,560,560,560,560,560,560,560,560,560,1690,560,1690,560,1690,560,1690,560,1690,560}; +int ARRAY_TEL[] = {4421,4447,560,1690,560,1690,560,1690,560,560,560,560,560,560,560,560,560,560,560,1690,560,1690,560,1690,560,560,560,560,560,560,560,560,560,560,560,1690,560,1690,560,1690,560,560,560,560,560,560,560,560,560,560,560,560,560,560,560,560,560,1690,560,1690,560,1690,560,1690,560,1690,560}; //DEFINE MY OUTPUTS "led" is IRLED connected on PC_0, "myled" is STM32 NUCLEO board-led DigitalOut myled(LED1); @@ -43,10 +46,10 @@ // DEFINE for each button pressed which is the array to send // IF any button is pressed the outputs level is 0 -int ARRAY_SEND[68]; +int ARRAY_SEND[67]; int i; - if(pushButton1 == 1) { for (i=0;i<68;i++) {ARRAY_SEND[i]=ARRAY_SOURCE[i];} } - else if(pushButton2 == 1) { for (i=0;i<68;i++) {ARRAY_SEND[i]=ARRAY_TEL[i];} } + if(pushButton1 == 1) { for (i=0;i<67;i++) {ARRAY_SEND[i]=ARRAY_SOURCE[i];} } + else if(pushButton2 == 1) { for (i=0;i<67;i++) {ARRAY_SEND[i]=ARRAY_TEL[i];} } else { // LEDs Turn-Off @@ -57,7 +60,7 @@ if (pushButton1==1 || pushButton2 ==1 ) { //From BIT 0 to the final BIT OF ARRAYSEND int BIT; -for (BIT = 0; BIT < 68; BIT ++) { +for (BIT = 0; BIT < 67; BIT ++) { //if the position of bit is even turn on the leds for bit value time, //if bit is odd turn off the leds for bit value time if ( BIT % 2==0) { @@ -69,4 +72,8 @@ myled =0; led =0; wait_us (ARRAY_SEND[BIT]);} + + myled =0; + led =0; + wait_us (9000); }}}} \ No newline at end of file