#include // import another program, a library, to communicate #define rxpin 1 #define txpin 0 SoftwareSerial serial(rxpin,txpin); //Declaring number to the different vararibles int rxPin = 1; // this is simular to the int = setting, however this is linked to the library//rxpin int txPin = 0; int trig = 3; // had first old pins stil in code int echo = 2; long lecture_echo; long cm; int PinRed = 6; int PinBlue = 7; int PinGreen = 5; //color amount used int Red_Amount = 100; int Blue_Amount = 100; int Green_Amount = 100; void setup() { pinMode(PinRed, OUTPUT); pinMode(PinBlue, OUTPUT); pinMode(PinGreen, OUTPUT); pinMode(trig, OUTPUT); digitalWrite(trig, LOW); pinMode(echo, INPUT); serial.begin(9600); } void loop() { digitalWrite(PinRed, HIGH); //High voltage delay(500); //delay of 500 milliseconds digitalWrite(PinRed, LOW); //low voltage digitalWrite(PinBlue, HIGH); delay(500); digitalWrite(PinBlue, LOW); digitalWrite(PinGreen, HIGH); delay(500); digitalWrite(PinGreen, LOW); digitalWrite(trig, HIGH); delayMicroseconds(10); digitalWrite(trig, LOW); lecture_echo = pulseIn(echo, HIGH); cm = lecture_echo / 58; serial.print ("Distance in cm: "); serial.println(cm); delay(1000); }