Coding Global Background
Coding Global

why does my super simple script work in reverse?

Archiviert a year ago
3 Nachrichten
2 Mitglieder
a year ago
In Discord öffnen
W
WatermelonPet
Verified

for context im using an arduino nano powering a laser emitter whenever digitalWrite happens ```#include <Arduino.h> #include <Wire.h> #include <SoftwareSerial.h> void setup() { pinMode(2,OUTPUT); pinMode(3,INPUT); } void loop() { if (digitalRead(3) == HIGH) digitalWrite(2,HIGH); else { digitalWrite(2,LOW); } } ``` Now, the problem is whenever i press the button (digitalRead high) it turns the light off rather than on anyone know why this could be happening?

Antworten (3)