Stap 4: Arduino Sketch
int ledblue = 2;
int tx = 1;
int rx = 0;
char inSerial [15];
void setup {Serial.begin(9600);
pinMode (ledblue, OUTPUT);
pinMode (tx, OUTPUT);
pinMode (rx, INPUT);
allpinslow();
}
void loop
{int i = 0;
int m = 0;
delay(500);
Als (Serial.available() > 0) {terwijl (Serial.available() > 0) {inSerial[i]=Serial.read();
i ++; }
inSerial [i] = '\0';
Check_Protocol(inSerial); }}
VOID allpinslow() {digitalWrite (ledblue, hoge);
digitalWrite (ledblue, laag); } void Check_Protocol (char inStr[]) {int i = 0;
int m = 0;
Serial.println(inStr);
if(!strcmp(inStr,"2off")) {//Led Off allpinslow();
digitalWrite (ledblue, laag); Serial.println ("Blue af");
voor (m = 0; m < 11; m ++) {inStr [m] = 0;} ik = 0;} if(!strcmp(inStr,"2on")) {//Led op allpinslow();
digitalWrite (ledblue, hoge);
Serial.println ("Blue op"); voor (m = 0; m < 11; m ++) {inStr [m] = 0;} ik = 0;} else {voor (m = 0; m < 11; m ++) {inStr [m] = 0;} ik = 0;
}}