____ _ ____ | _ \ ___ | |__ ___/ ___| _ _ _ __ ___ ___ | |_) / _ \| '_ \ / _ \___ \| | | | '_ ` _ \ / _ \ | _ < (_) | |_) | (_) |__) | |_| | | | | | | (_) | |_| \_\___/|_.__/ \___/____/ \__,_|_| |_| |_|\___/ ____ _ _ _ / ___|___ ___ | | _| |__ ___ ___ | | __ | | / _ \ / _ \| |/ / '_ \ / _ \ / _ \| |/ / | |__| (_) | (_) | <| |_) | (_) | (_) | < \____\___/ \___/|_|\_\_.__/ \___/ \___/|_|\_\
Here's a paragraph of text. Write your blog posts in markdown.
//
// Sensor voltage measurement example for Arduino Nano
// Author: Ted Burke
// Date: 14-Feb-2024
//
void setup()
{
Serial.begin(9600); // open serial connection to PC at 9600 bits/second
}
void loop()
{
int left_sensor, right_sensor;
left_sensor = analogRead(0); // read analog voltage from pin A0
right_sensor = analogRead(1); // read analog voltage from pin A1
Serial.print("0,1023,");
Serial.print(left_sensor);
Serial.print(",");
Serial.println(right_sensor);
// operators in C / C++
if (left_sensor > 512 && right_sensor < 512)
{
// motor forward
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
}
else
{
// motor stop
digitalWrite(4, LOW);
digitalWrite(5, LOW);
}
delay(10);
}