/* Week 16 - Interface and Application Programming * On press, turn on the corresponding colour. * http://archive.fabacademy.org/2018/labs/fablabirbid/students/shefa-jaber/Interface.HTML * * Modified by Michael O: 15.05.19 * */ // Changed the pin numbers #define red 6 #define green 5 #define blue 3 void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(red,OUTPUT); pinMode(green, OUTPUT); pinMode(blue, OUTPUT); } void loop() { // put your main code here, to run repeatedly: int data=Serial.read(); switch (data){ case '0': setColor(0, 255, 255); // Red Color break; case '1': setColor(255, 255, 0); // Green Color break; case '2': setColor(255, 0, 255); // Blue Color break; case '3': setColor(0, 0, 0); // White Color break; } } void setColor(int redValue, int greenValue, int blueValue) { analogWrite(red, redValue); analogWrite(green, greenValue); analogWrite(blue, blueValue); }