void loop() { if (Serial.available() > 0) { // if the data came incomingByte = Serial.read(); // read byte if(incomingByte == '0') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off Serial.println("All LEDs are OFF. Press 1 to RED LED ON! Press 2 to BLUE LED ON! Press 3 to GREEN LED ON!"); // print message } if(incomingByte == '1') { digitalWrite(LED1, HIGH); // if 0, switch LED on Serial.println("RED LED is now ON. Press 0 to have all LED OFF!"); } if(incomingByte == '2') { digitalWrite(LED2, HIGH); // if 0, switch LED on Serial.println("BLUE LED is now ON. Press 0 to have all LED OFF!"); } if(incomingByte == '3') { digitalWrite(LED3, HIGH); // if 0, switch LED on Serial.println("GREEN LED is now ON. Press 0 to have all LED OFF!"); } }}

void loop() { if (Serial.available() > 0) { // if the data came incomingByte = Serial.read(); // read byte if(incomingByte == '0') { digitalWrite(LED1, HIGH); // if 0, switch LED on digitalWrite(LED2, HIGH); // if 0, switch LED on digitalWrite(LED3, HIGH); // if 0, switch LED on delay (100); digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off Serial.println("All LEDs are OFF."); // print message Serial.println("Press 1 to RED LED ON!"); Serial.println("Press 2 to BLUE LED ON!"); Serial.println("Press 3 to GREEN LED ON!"); Serial.println("Press 4 to RED & BLUE LEDs ON!"); Serial.println("Press 5 to RED & GREEN LEDs ON!"); Serial.println("Press 6 to BLUE & GREEN LEDs ON!"); Serial.println("Press 7 to RED & BLUE & GREEN LEDs ON!"); } if(incomingByte == '1') { // first all LEDs will be OFF digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED1, HIGH); // if 0, switch LED on Serial.println("RED LED is now ON. Press 0 to have all LED OFF!"); } if(incomingByte == '2') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED2, HIGH); // if 0, switch LED on Serial.println("BLUE LED is now ON. Press 0 to have all LED OFF!"); } if(incomingByte == '3') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED3, HIGH); // if 0, switch LED on Serial.println("GREEN LED is now ON. Press 0 to have all LED OFF!"); } if(incomingByte == '4') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED1, HIGH); // if 0, switch LED on digitalWrite(LED2, HIGH); // if 0, switch LED on Serial.println("RED & BLUE LEDs is now ON. Press 0 to have all LED OFF!"); } if(incomingByte == '5') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED1, HIGH); // if 0, switch LED on digitalWrite(LED3, HIGH); // if 0, switch LED on Serial.println("RED & GREEN LEDs is now ON. Press 0 to have all LED OFF!"); } if(incomingByte == '6') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED2, HIGH); // if 0, switch LED on digitalWrite(LED3, HIGH); // if 0, switch LED on Serial.println("BLUE & GREEN LEDs is now ON. Press 0 to have all LED OFF!"); } if(incomingByte == '7') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED1, HIGH); // if 0, switch LED on digitalWrite(LED2, HIGH); // if 0, switch LED on digitalWrite(LED3, HIGH); // if 0, switch LED on Serial.println("RED & BLUE & GREEN LEDs is now ON. Press 0 to have all LED OFF!"); } }}iar filmuletul, care prezinta functionarea se numeste Arduino and bluetooth module (V)

void loop() { if (Serial.available() > 0) { // if the data came incomingByte = Serial.read(); // read byte if(incomingByte == '0' || incomingByte == '8' || incomingByte == '9') { // digitalWrite(LED1, HIGH); // if 0, switch LED on // digitalWrite(LED2, HIGH); // if 0, switch LED on // digitalWrite(LED3, HIGH); // if 0, switch LED on // delay (10); digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off Serial.println("All LEDs are OFF."); // print message Serial.println("Press 1 to RED LED ON!"); Serial.println("Press 2 to BLUE LED ON!"); Serial.println("Press 3 to GREEN LED ON!"); Serial.println("Press 4 to RED & BLUE LEDs ON!"); Serial.println("Press 5 to RED & GREEN LEDs ON!"); Serial.println("Press 6 to BLUE & GREEN LEDs ON!"); Serial.println("Press 7 to RED & BLUE & GREEN LEDs ON!"); } if(incomingByte == '1') { // first all LEDs will be OFF digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED1, HIGH); // if 0, switch LED on Serial.println("RED LED is now ON. Press 0, 8 or 9 to have all LED OFF!"); } if(incomingByte == '2') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED2, HIGH); // if 0, switch LED on Serial.println("BLUE LED is now ON. Press 0, 8 or 9 to have all LED OFF!"); } if(incomingByte == '3') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED3, HIGH); // if 0, switch LED on Serial.println("GREEN LED is now ON. Press 0, 8 or 9 to have all LED OFF!"); } if(incomingByte == '4') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED1, HIGH); // if 0, switch LED on digitalWrite(LED2, HIGH); // if 0, switch LED on Serial.println("RED & BLUE LEDs is now ON. Press 0, 8 or 9 to have all LED OFF!"); } if(incomingByte == '5') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED1, HIGH); // if 0, switch LED on digitalWrite(LED3, HIGH); // if 0, switch LED on Serial.println("RED & GREEN LEDs is now ON. Press 0, 8 or 9 to have all LED OFF!"); } if(incomingByte == '6') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED2, HIGH); // if 0, switch LED on digitalWrite(LED3, HIGH); // if 0, switch LED on Serial.println("BLUE & GREEN LEDs is now ON. Press 0, 8 or 9 to have all LED OFF!"); } if(incomingByte == '7') { digitalWrite(LED1, LOW); // if 1, switch LED Off digitalWrite(LED2, LOW); // if 1, switch LED Off digitalWrite(LED3, LOW); // if 1, switch LED Off digitalWrite(LED1, HIGH); // if 0, switch LED on digitalWrite(LED2, HIGH); // if 0, switch LED on digitalWrite(LED3, HIGH); // if 0, switch LED on Serial.println("RED & BLUE & GREEN LEDs is now ON. Press 0, 8 or 9 to have all LED OFF!"); } }}