Question: MY issue : im currently trying to get this code to output a (high) on my led once it past min and max vaule from

MY issue : im currently trying to get this code to output a (high) on my led once it past min and max vaule from the adxl335 sensor everything seems to work but im having iisues with outputing my Analog vaule to a digital pin im not quite sure how to declare it with this esp8266MOD12-e module please help

software im using :Arduino IDE , nodemcu 12-e

the hardware im using : im using a esp8266MOD12-e module and a adxl335 gy- 61 sensor

please help im stuck

_________________________________

int sensorValue = 0; // variable to store the value coming from the sensor

long y_max = 408;

long y_min = 385;

const int D1 = 5;

const int yPin = A0; //x-axis of the Accelerometer

void setup() {

// initialize serial communications at 9600 bps:

Serial.begin(9600);

pinMode(yPin,INPUT);

pinMode(D1, OUTPUT);

digitalWrite(D1, LOW);

}

void loop() {

int y = analogRead(yPin);

delay(100);

Serial.print("y-axis : ");

Serial.println(y); // y-axis

if (yPin > y_max) { //backwards

digitalWrite(D1, HIGH);

Serial.println("The arduino is moving(tilted) backwards");

} else if (yPin < y_min) { //forwards

digitalWrite(D1, LOW);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!