Arduino Tutorials – Lesson 42 – LDR Sensor on Raspberry Pi Pico

To control LDR Sensor using Raspberry Pi Pico Board

Required Components

  1. LDR Sensor_1 no
  2. Raspberry Pi Pico board_1 no
  3. Connecting wires_1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Raspberry Pi Pico GP27 pin to the LDR D0 pin.
  3. Connect the Raspberry Pi Pico 3V3 (OUT) pin to the LDR +5V pin.
  4. Connect the Raspberry Pi Pico GND to the LDR GND pin.
  5. Check the Arduino program.
  6. Check the Electrical circuit.
  7. Run the Arduino program.

Arduino Program

const int ledPin=25;
const int ldrPin=27;

void setup(  )
{
  Serial.begin(9600);
  pinMode (ledPin,OUTPUT);
  pinMode (ldrPin,INPUT);
}

void loop( )
{
  int ldrstatus = analogRead(ldrPin);
  if (ldrstatus<=300)
 {
    digitalWrite(ledPin,HIGH);
    Serial.print("LDR in Dark,LED is ON");
  }
  else
  {
    digitalWrite(ledPin,LOW);
    Serial.print ("LDR in Light,LED Is Off");
  }
}

Arduino Tutorials – Lesson 41 – Position Encoder sensor using Raspberry Pi Pico

To get the reading of position encoder sensor direction change using Raspberry Pi Pico

Required Components

  1. Position encoder sensor_1 no
  2. Raspberry Pi Pico_1 no
  3. Connecting Wires_4 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the position encoder sensor CLK pin to the Raspberry Pi Pico GP8.
  3. Connect the position encoder sensor DT pin to the Raspberry Pi Pico GP9.
  4. Connect the +5v and ground(gnd) connections respectively.
  5. Check the Arduino program.
  6. Check the Electrical Circuit.
  7. Run the Arduino program.

Arduino Program

#define outputA 8
#define outputB 9
int counter = 0;
int aState;
int aLastState;

void setup() 
{
 pinMode (outputA,INPUT);
 pinMode (outputB,INPUT);
 Serial.begin (9600);
 aLastState = digitalRead(outputA);
}

void loop() 
{
 aState = digitalRead(outputA); // Reads the "current" state of the outputA
 if (aState != aLastState)
{
  if (digitalRead(outputB) != aState)
 {
   counter ++;
  } else {
  counter --;
  }
  Serial.print("Position: ");
  Serial.println(counter);
 }
 aLastState = aState;
}

Arduino Tutorials – Lesson 40 – Sweep Servo Motor Control Using Raspberry Pi Pico

To test servo motor using Raspberry Pi Pico

Required Components

  1. Servo motor (5V) _ 1 no
  2. Raspberry Pi Pico board _ 1 no
  3. Connecting wires _ 1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect Raspberry Pi Pico board VBus and GND pin to the servo motor by using wires.
  3. Connect servo motor data pin to the Raspberry Pi Pico pin GP15.
  4. Check the Arduino program.
  5. Check the circuit connections.
  6. Run the Arduino program.

Arduino Program

#include<Servo.h>
Servo servo1;

void setup(  )
{
  servo1.attach(15);
}

void loop(  )
{
  servo1.write(0);
  delay(1000);
  servo1.write(90);
  delay(1000);
  servo1.write(180);
  delay(1000);
}

Arduino Tutorials – Lesson 39 – Single LED Control With Single Pushbutton

To check single LED blink using push button

Required Components

  1. LED _ 1 no
  2. 220 Ω Resistor_ 1 no
  3. 10 K Ω Resistor _1 no
  4. Pushbutton _1 no
  5. Bread Board _1 no
  6. Raspberry Pi Pico _1 no
  7. Connecting wires _1 Set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect Raspberry Pi Pico board VBus and GND pin to the bread board by using wires.
  3. Connect 220 Ω Resistor to the LED Anode (+) pin and cathode (-) pin to Gnd.
  4. Connect 220 Ω Resistor another pin to GP16.
  5. Connect 10 k Ω Resistor to the switch button.
  6. Connect switch button another pin to the Raspberry Pi Pico pin GP17.
  7. When we press the push button LED blinks.
  8. Check the Arduino program.
  9. Check the circuit connections.
  10. Run the Arduino program.

Arduino Program

int ledPin = 16;
int buttonPin = 17;

void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
}


void loop()
{  
  int button = digitalRead(buttonPin);
  if (button==HIGH)
  {
    digitalWrite(ledPin,HIGH);
  } 
  else
  {
    digitalWrite(ledPin, LOW);
   }
}

Arduino Tutorials – Lesson 38 – Use A Buzzer Module Using Raspberry Pi Pico

To control Buzzer using Raspberry Pi Pico

Required Components

  1. Buzzer module _ 1 no
  2. Raspberry Pi Pico _ 1 no
  3. Connecting wires _ 1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Raspberry Pi Pico board GP15th pin to the Buzzer.
  3. Connect Buzzer board GND to GND of Raspberry Pi Pico Board.
  4. Check the Electrical Circuit.
  5. Check the Arduino program.
  6. Run the Arduino program.

Arduino Program

const int buzzer = 15;

void setup( )
{
  pinMode(buzzer, OUTPUT);
}

void loop()
{
  tone(buzzer, 1000);
  delay(1000);
  noTone(buzzer);
  delay(1000);        
}

Arduino Tutorials – Lesson 37 – Double led blink using Raspberry Pi Pico

To check double LED blink using Raspberry Pi Pico

Required Components

  1. Led _ 2 no
  2. Raspberry Pi Pico board _ 1 no
  3. Connecting wires _ 1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect Led GND pins to Raspberry Pi Pico GND pins respectively.
  3. Connect Raspberry Pi Pico GP2, GP20 pins to the each LED anode pins.
  4. Check the Arduino program.
  5. Check the circuit connections.
  6. Run the Arduino program.

Arduino Program

int Led1 = 2;
int Led2 = 20;

void setup() 
{
  pinMode(Led1, OUTPUT);
  pinMode(Led2, OUTPUT);

}

void loop() 
{
  digitalWrite(Led1, HIGH);
  digitalWrite(Led2, HIGH);
  delay(1000);

  digitalWrite(Led1, LOW);
  digitalWrite(Led2, LOW);
  delay(1000);
}

Arduino Tutorials – Lesson 36 – Single LED Blink Using Raspberry Pi Pico

To check single LED blink using Raspberry Pi Pico.

Required Components

  1. Led _1 no
  2. Resister 330Ω _1 no
  3. Raspberry Pi Pico board _1 no
  4. Connecting wires _1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect 330 Ω Resistor to the LED Anode (+) pin and LED cathode (-) pin to Gnd.
  3. Connect Raspberry Pi Pico pin 28 to the LED anode pin.
  4. Check the Arduino program.
  5. Check the circuit connections.
  6. Run the Arduino program.

Arduino Program

int led1 = 28;

void setup ( )
{
  pinMode (led1, OUTPUT);
}

void loop ( )
{
  digitalWrite (led1, HIGH);
  delay (3000);
  digitalWrite (led1, LOW);
  delay (1000);
}