رسم تخطيطي قبل المتابعة ، تحتاج إلى تجميع دائرة بمصباح LED وزر ضغط. سنقوم بتوصيل مؤشر LED بـ GPIO 5 (D1) وزر الضغط بـ GPIO 4 (D2).
المكونات الاساسية :
- Nodemcu ESP8266
- Push Button
- 10k Ohm Resistor
- Breadboard
- 5 mm LED
- Jumper wires
++ مخطط الرسم البياني :
++ الكود البرمجي هنا :
// set pin numbers
const int buttonPin = 4; // the number of the pushbutton pin
const int ledPin = 5; // the number of the LED pin
// variable for storing the pushbutton status
int buttonState = 0;
void setup() {
// initialize the pushbutton pin as an input
pinMode(buttonPin, INPUT);
// initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the state of the pushbutton value
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH
if (buttonState == HIGH) {
// turn LED on
digitalWrite(ledPin, HIGH);
} else {
// turn LED off
digitalWrite(ledPin, LOW);
}
}
#arduino #arduinoproject #raspberrypi #robotic #arduinouno #microcontroller #diyelectronics #electronicengineering #ohms #embedded #electricalhacks #electronicsengineering #techgadget #electronicsprojects #adafruit #embeddedsystems #digitalelectronics #arduinolove #esp32 #electronique #microcontrollers #electronicsquestions #electronicprojects #electronicsbasic #printedcircuitboard #arduinonano #arduinoprojects #resistor #electronicslovers #arduinofun
No comments:
Post a Comment