Posts

Showing posts from January, 2023

Led Blink Arduino Project Diagram

  LED anode -> Digital Pin 13 LED cathode -> GND

Arduino Blink Led Code

  const int LED_PIN = 13; void setup() { pinMode(LED_PIN, OUTPUT); } void loop() { digitalWrite(LED_PIN, HIGH); delay(1000); digitalWrite(LED_PIN, LOW); delay(1000); }

Arduino PIR Motion Sensor Code

const int pirPin = 2; // the pin the PIR sensor is connected to const int ledPin = 9; // the pin the LED is connected to void setup() { pinMode(pirPin, INPUT); // set the pin with the PIR sensor as an input pinMode(ledPin, OUTPUT); // set the pin with the LED as an output } void loop() { // read the state of the PIR sensor int pirState = digitalRead(pirPin); // check if the PIR sensor is detecting motion if (pirState == HIGH) { // turn the LED on digitalWrite(ledPin, HIGH); } else { // turn the LED off digitalWrite(ledPin, LOW); } }

Diagram of PIR Motion Sensor

  Here is a simple project you can do with a PIR (passive infrared)sensor and an LED and Buzzer; 1. Connect the positive leg of the LED (the longer leg)to digital pin 9 on the Arduino. 2.connect the negative leg of the LED(the shorted leg)to a ground pin on the Arduino 3. connect the VCC pin on the PIR sensor to 5V on the Arduino 4. connect the GND pin on the PIR sensor to a ground pin on the Arduino. 5. connect the OUT   pin on the PIR sensor to digital pin 2 on the   Arduino.    

Arduino Touch Sensor Diagram

  Here is a simple diagram of Arduino with a Touch Sensor 1. Connect the positive leg of the LED to digital pin 9 on the Arduino. 2. Connect the negative leg of the LED to any ground pin on Arduino. 3. Connect the VCC on the Touch sensor to 5v on the Arduino 4. Connect the GND pin on the Touch sensor to any ground pin on the Arduino. 5. Connect the OUT pin on the Touch sensor to digital pin 2 on the Arduino.

Arduino Touch Sensor Code

const int touchPin = 2; // the pin the touch sensor is connected to const int ledPin = 9; // the pin the LED is connected to void setup() { pinMode(touchPin, INPUT); // set the touch pin as an input pinMode(ledPin, OUTPUT); // set the LED pin as an output } void loop() { // read the state of the touch sensor int touchState = digitalRead(touchPin); // check if the touch sensor is being pressed if (touchState == HIGH) { // turn the LED on digitalWrite(ledPin, LOW); } else { // turn the LED off digitalWrite(ledPin, HIGH); } }

Arduino Delete Code

  void setup() { // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: }