Question: *ARDUINO ERROR PLEASE* I have to write an Arduino code that turns on the LED when an impact is detected. ( The LED I'm going

*ARDUINO ERROR PLEASE*

I have to write an Arduino code that turns on the LED when an impact is detected. (The LED I'm going to use is FAST LED).

It doesn't work. Please correct the code error so that it works well. And if there's anything weird in general, please correct it.

PLEASE...

#define SHOCK 8

void setup() { Serial.begin(9600); pinMode(SHOCK, INPUT);

}

void loop() { if (digitalRead (SHOCK ) == HIGH) { Serial.println("SHOCK!!!");

}

delay (100); } void loop() {

if (digitalRead (SHOCK) == HIGH)

const int ledPin = 13;

int ledState = LOW;

long previousMillis = 0;

long interval = 1000; }

void setup() {

pinMode(ledPin, OUTPUT);}

void loop()

{

unsigned long currentMillis = millis();

if(currentMillis - previous Millis > interval) {

previousMillis = currentMillis;}

if (ledState LOW) == ledState = HIGH;

else ledState = LOW;

digitalWrite(ledPin, ledState); }

if(currentMillis - previous Millis > interval) {

previousMillis = currentMillis;}

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!