Question
ARDUINO CODING HELP CODE WORKS NEED HELP DISPLAYING CODE ON OLED DISPLAY SCREEN AS WELL AS SHOWING THE THRESHOLD int sensorPin = A0; // select
ARDUINO CODING HELP
CODE WORKS NEED HELP DISPLAYING CODE ON OLED DISPLAY SCREEN AS WELL AS SHOWING THE THRESHOLD
int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
// These constants won't change:
const int analogPin = A0; // pin that the sensor is attached to
const int ledPin = 12; // pin that the LED is attached to
const int threshold = 585; // threshold level that's in the range of the analog input
const int yLED = A2;
const int ap2 = A4;
int sv2 = 0;
int ov2= 0;
void setup1() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void setup2() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop1() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for
delay(sensorValue);
}
void loop2() {
analogReference(EXTERNAL); //connect 3.3v to AREF
sv2 = analogRead(ap2);
ov2 = map(sv2, 0, 1023, 0, 255);
delay(2);
// print the results to the serial monitor:
Serial.print("Ysensor2 = " );
Serial.print(sv2);
Serial.print("\t output2 = ");
Serial.println(ov2);
int analogValue = analogRead(analogPin);
// if the analog value is high enough, turn on the LED:
if (sv2 < threshold) {
Serial.print("This is the threshold");
Serial.print("\t ");
}
// print the analog value:
if (sv2 < threshold)
{
digitalWrite(yLED, HIGH);
}
else // it's NOT > threshold
{
digitalWrite(yLED, LOW);
}
delay(1000); // delay in between reads for stability
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started