The original “Child,” which was the Arduino Uno I used MUCH earlier has been brought back up for a new project.
/*
This will be my iteration of an ultrasonic distance sensor sending a signal and determining how close something is via an RGB LED and a peizo
*/
#include <Ultrasonic.h>
Ultrasonic ultrasonic(12,13);
int distance;
const int redPin = 3;
const int greenPin = 5;
const int bluePin = 6;
void setup() {
Serial.begin(9600);
}
void loop() {
distance = ultrasonic.read();
Serial.print("Distance is CM: ");
Serial.println(distance);
delay(500);
}
I know it’s unprofessional to just DUMP my code, BUT this is being done on a separate device, so I have to type it WORD FOR WORD.
if you know “import” in Python, then “#include <library.h>” is the same thing
Right now, most of this code only initializes. The rest of it is for the Ultrasonic Distance Sensor (UDS).
Quickfire now: “distance” just stores the distance from the UDS, “Serial.print()” returns text in the serial monitor and “Serial.println()” does the same without making a new line, “delay()” is a delay, and GOD FORBID should you forget the semicolon (;) in ANY form of C++.
Leave a Reply