code for sterring wheel interface

Dependencies:   MBC002-DigitalIn

Revision:
3:82270ac03cb7
Parent:
2:7c5890e1af90
Child:
4:faec61d0b6c0
diff -r 7c5890e1af90 -r 82270ac03cb7 main.cpp
--- a/main.cpp	Wed Jun 27 10:11:24 2018 +0000
+++ b/main.cpp	Wed Jun 27 11:33:57 2018 +0000
@@ -1,8 +1,8 @@
 #include "mbed.h"
 
 // DEFINE AN ARRAY FOR EACH COMMAND I NEED
-short ARRAY_SOURCE[] = {10,5,10,5,10,5,10,5,};
-short ARRAY_TEL[] = {5,10,5,10,5,10,5,10,};
+int ARRAY_SOURCE[] = {10,5,10,5,10,5,10,5,};
+int ARRAY_TEL[] = {5,10,5,10,5,10,5,10,};
 
 
 //DEFINE MY OUTPUTS "led" is IRLED connected on PC_0, "myled" is STM32 NUCLEO board-led
@@ -41,9 +41,9 @@
 // DEFINE for each button pressed which is the array to send
 // IF any button is pressed the outputs level is 0
 int ARRAY_SEND;
-
-       if(pushButton1 == 1)  {int ARRAY_SEND[] = ARRAY_SOURCE;}
-  else if(pushButton2 == 1)  {int ARRAY_SEND[] = ARRAY_TEL;}
+int i;
+       if(pushButton1 == 1)  {for (i=0;i<8;i++){ARRAY_SEND[i]=ARRAY_SOURCE[i];}}
+  else if(pushButton2 == 1)  {for (i=0;i<8;i++){ARRAY_SEND[i]=ARRAY_TEL[i];}}
         else {
             
             // LEDs Turn-Off
@@ -54,10 +54,11 @@
 // ASSIGN to a variable the size of ARRAYSEND
 
 //From BIT 0 of ARRAY_SEND to the final BIT OF ARRAYSEND
-for (BIT = 0; i < 4; i ++) {
+int BIT;
+for (BIT = 0; i < 8; i ++) {
 //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)) {           
+  if ( BIT % 2==0) {           
              myled =1;
               led =1;
              wait (ARRAY_SEND[BIT]);}