Arduino Tutorials – பாடம் 41 – Position Encoder sensor using Raspberry Pi Pico

Raspberry Pi Pico வை பயன்படுத்தி ஒரு position encoder ஐ அளவீடு செய்வது.

Required Components

  1. Position encoder sensor-1 no
  2. Raspberry Pi Pico-1 no
  3. Connecting Wires-1 set

Circuit

Steps

  1. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. Position encoder sensorல் உள்ள CLK மற்றும் DT பின்களை Raspberry Pi Pico வில் உள்ள GP8 மற்றும் GP9 பின்களுடன் இணைக்க வேண்டும்.
  3. Position encoder ன் +5V மற்றும் ground சப்ளையை Raspberry Pi Pico 3V3 (OUT) மற்றும் gnd உடன் இணைக்க வேண்டும்.
  4. Arduino program ஐ சரி பார்க்க வேண்டும்.
  5. மின்சுற்றை சரி பார்க்க வேண்டும்.
  6. 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 – பாடம் 40 – Sweep Servo Motor Control Using Raspberry Pi Pico

Raspberry Pi Pico வை பயன்படுத்தி Servo மோட்டாரை சுற்ற வைப்பது

Required Components

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

Circuit

Steps

  1. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. Servo மோட்டாருக்கு மூன்று இணைப்புகள் உள்ளன, அதில் ஒன்று data pin, +5v மற்றும் ground.
  3. Raspberry Pi Pico GP15 ஆவது இணைப்பை நேரடியாக மோட்டார் உடன் இணைக்க வேண்டும்.
  4. Servo வில் உள்ள +5v மற்றும் ground ஐ Raspberry Pi Pico VBus மற்றும் gnd உடன் இணைக்க வேண்டும்.
  5. Arduino program ஐ சரி பார்க்க வேண்டும்.
  6. மின்சுற்றை சரி பார்க்க வேண்டும்.
  7. 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 – பாடம் 39 – Single LED Control With Single Pushbutton

ஒரு புஷ் பட்டன் ஐ பயன்படுத்தி ஒரு LEDஐ ஒளிர வைப்பது

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. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. இரண்டு வகையான மின்தடைகளை எடுத்து கொள்ளவும் ஒன்று 10K மற்றறொன்று 220 Ohm.
  3. 220Ohm மின்தடையை LED உடனும் 10K மின்தடையை சுவிட்ச் உடனும் இணைக்க வேண்டும்.
  4. அந்த புஷ்பட்டன் ஐ Raspberry Pi Pico GP17 உடன் இணைக்க வேண்டும்.
  5. 220Ohm மின்தடையை LED + உடன் மற்றும் LED – ஐ GND உடன் இணைக்க வேண்டும்.
  6. 220Ohm மின்தடையை Raspberry Pi Pico GP16 உடன் இணைக்க வேண்டும்.
  7. புஷ் பட்டன் ஐ அழுத்தும் போது LED ஒளிர வேண்டும்.
  8. Arduino program ஐ சரி பார்க்க வேண்டும்.
  9. மின்சுற்றை சரி பார்க்க வேண்டும்.
  10. 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 – பாடம் 38 – Use A Buzzer Module Using Raspberry Pi Pico

Raspberry Pi Pico வை பயன்படுத்தி Buzzer (ஒலிப்பான்) ஐ கட்டுபடுத்துவது.

Required Components

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

Circuit

Steps

  1. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. Buzzer (ஒலிப்பான்) ஐ Raspberry Pi Pico GP15உடன் இணைக்க வேண்டும்.
  3. Buzzer (ஒலிப்பான்) Ground உடன் Raspberry Pi Pico Ground ஐ இணைக்க வேண்டும்.
  4. Arduino program ஐ சரி பார்க்க வேண்டும்.
  5. மின்சுற்றை சரி பார்க்க வேண்டும்.
  6. Arduino program ஐ ரன் செய்ய வேண்டும்.

Arduino Program

const int buzzer = 8;

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

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

Arduino Tutorials – பாடம் 37 – Double led blink using Raspberry Pi Pico

Raspberry Pi Pico வை பயன்படுத்தி இரண்டு LED ஐ ஒளிர வைப்பது.

Required Components

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

Circuit

Steps

  1. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. 2 LED வில் உள்ள ground இணைப்புகளை Raspberry Pi Pico வில் உள்ள ground உடன் இணைக்க வேண்டும்.
  3. Raspberry Pi Pico GP2, GP20 உடன் 2 LED + யை இணைக்க வேண்டும்.
  4. Arduino program ஐ சரி பார்க்க வேண்டும்.
  5. மின்சுற்றை சரி பார்க்க வேண்டும்.
  6. 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 – பாடம் 36 – Single LED Blink Using Raspberry Pi Pico

Raspberry Pi Pico வை பயன்படுத்தி ஒரு LED ஐ ஒளிர வைப்பது.

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. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. 330 Ω மின்தடையை LED உடன் இணைக்க வேண்டும்.
  3. LED இன் அடுத்த இணைப்பை ground உடன் இணைக்க வேண்டும்.
  4. Arduino program ஐ சரி பார்க்க வேண்டும்.
  5. மின்சுற்றை சரி பார்க்க வேண்டும்.
  6. Arduino program ஐ ரன் செய்ய வேண்டும்.

Arduino Program

int led1 = 28;

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

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

Python Tutorials – Lesson 13 – L298N Motor Driver Module control double DC Motor using Raspberry Pi Pico

To control 2 DC motors with directional and speed control

Required Components

  1. L298N Motor Driver Module_1 no
  2. Raspberry Pi Pico_1 no
  3. DC Motor(gear)_2 no
  4. 12V Battery_1 no
  5. Data Cable_1 no
  6. Connecting Wires_4 no

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the 12V Battery to the L298N Motor Driver.
  3. Connect the ENA, IN1, IN2, IN3, IN4, ENB pins to the Raspberry Pi Pico board pins GP7, GP5, GP4, GP3, GP2, GP6 properly.
  4. Connect the DC motor pins to the motor driver output pins.
  5. Connect the ground connection respectively.
  6. Check the Electrical Circuit.
  7. Check the Python program.
  8. Run the Python program.

Python Program

from machine import Pin
import utime
 
m1 = Pin(5, Pin.OUT)
m2 = Pin(4, Pin.OUT)
m3 = Pin(3, Pin.OUT)
m4 = Pin(2, Pin.OUT)
 
en1 = Pin(6, Pin.OUT)
en2 = Pin(7, Pin.OUT)
 
en1(1)  # motor 1 enable, set value 0 to disable
en2(1)  # motor 2 enable, set value 0 to disable
 
while True:
    #Both Motor in forward direction
    m1(1)
    m2(0)
    m3(1)
    m4(0)
    utime.sleep(1)
    #Both Motor in Reverse direction
    m1(0)
    m2(1)
    m3(0)
    m4(1)
    utime.sleep(1)
    #Both Motor in stop position
    m1(0)
    m2(0)
    m3(0)
    m4(0)
    utime.sleep(5)
    

Python Tutorials – Lesson 12 – L298N Motor Driver Module control single DC Motor using Raspberry Pi Pico

To control 1 DC motor with directional and speed control

Required Components

  1. L298N Motor Driver Module_1 no
  2. Raspberry Pi Pico_1 no
  3. DC Motor(gear)_1 no
  4. 12V Battery_1 no
  5. Data Cable_1 no
  6. Connecting Wires_4 no

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the 12V Battery to the L298N Motor Driver.
  3. Connect the ENA, IN1, IN2 pins to the Raspberry Pi Pico board pins GP4, GP2, GP3 properly.
  4. Connect the DC motor pins to the motor driver output pins.
  5. Connect the ground connection respectively.
  6. Check the Electrical Circuit.
  7. Check the Python program.
  8. Run the Python program.

Python Program

from machine import Pin
import utime
 
m1 = Pin(2, Pin.OUT)
m2 = Pin(3, Pin.OUT)
 
en1 = Pin(4, Pin.OUT)
 
en1(1)  # motor 1 enable, set value 0 to disable
 
while True:
    #Both Motor in forward direction
    m1(1)
    m2(0)
    utime.sleep(1)
    #Both Motor in Reverse direction
    m1(0)
    m2(1)
    utime.sleep(1)
    #Both Motor in stop position
    m1(0)
    m2(0)
    utime.sleep(5)

Python Tutorials – Lesson 15 – 4×4 Matrix Keypad Module using Raspberry Pi Pico

To control 4×4 Matrix Keypad Module using Raspberry Pi Pico

Required Components

  1. 4×4 Matrix Keypad_1 no
  2. Raspberry Pi Pico board_1 no
  3. Data Cable_1 no
  4. Connecting Wires_8 no

Circuit

Steps

  1. Make sure the components are working properly.
  2. 4×4 Matrix keypad 1 to 8 pins connected to GP1 to GP8 of Raspberry Pi Pico Board respectively.
  3. Check the Python program.
  4. Check the Electrical Circuit.
  5. Run the Python program.

Python Program

from machine import Pin
import utime

# define PINs according to cabling
# following array matches 1,2,3,4 PINs from 4x4 Keypad Matrix
col_list=[1,2,3,4]
# following array matches 5,6,7,8 PINs from 4x4 Keypad Matrix
row_list=[5,6,7,8]

# set row pins to output and change array elements from
#    int to Pin objects, all set to high
for x in range(0,4):
    row_list[x]=Pin(row_list[x], Pin.OUT)
    row_list[x].value(1)

# set columns pins to input and change array elements 
#   from int to Pin objects. We'll read user input here
for x in range(0,4):
    col_list[x] = Pin(col_list[x], Pin.IN, Pin.PULL_UP)

# Create a map between keypad buttons and chars
key_map=[["D","#","0","*"],\
         ["C","9","8","7"],\
         ["B","6","5","4"],\
         ["A","3","2","1"]]

def Keypad4x4Read(cols,rows):
  for r in rows:
    r.value(0)
    result=[cols[0].value(),cols[1].value(),cols[2].value(),cols[3].value()]
    if min(result)==0:
      key=key_map[int(rows.index(r))][int(result.index(0))]
      r.value(1) # manages key keept pressed
      return(key)
    r.value(1)

# Start the main loop
print("--- Ready to get user inputs ---")
while True:
    key=Keypad4x4Read(col_list, row_list)
    if key != None:
      print("You pressed: "+key)
      utime.sleep(0.3) # gives user enoght time to release without having double inputs

Python Tutorials – Lesson 14 – 4×3 Matrix Keypad Module using Raspberry Pi Pico

To control 4×3 Matrix Keypad Module using Raspberry Pi Pico

Required Components

  1. 4×3 Matrix Keypad_1 no
  2. Raspberry Pi Pico board_1 no
  3. Data Cable_1 no
  4. Connecting Wires_8 no

Circuit

Steps

  1. Make sure the components are working properly.
  2. 4×3 Matrix keypad 1 to 7 pins connected to GP1 to GP7 of Raspberry Pi Pico Board respectively.
  3. Check the Python program.
  4. Check the Electrical Circuit.
  5. Run the Python program.

Python Program

from machine import Pin
import utime

# define PINs according to cabling
# following array matches 1,2,3 PINs from 3x4 Keypad Matrix
col_list=[1,2,3]
# following array matches 4,5,6,7 PINs from 3x4 Keypad Matrix
row_list=[4,5,6,7]

# set row pins to output and change array elements from
#    int to Pin objects, all set to high
for x in range(0,4):
    row_list[x]=Pin(row_list[x], Pin.OUT)
    row_list[x].value(1)

# set columns pins to input and change array elements 
#   from int to Pin objects. We'll read user input here
for x in range(0,3):
    col_list[x] = Pin(col_list[x], Pin.IN, Pin.PULL_UP)

# Create a map between keypad buttons and chars
key_map=[["#","0","*"],\
         ["9","8","7"],\
         ["6","5","4"],\
         ["3","2","1"]]

def Keypad3x4Read(cols,rows):
  for r in rows:
    r.value(0)
    result=[cols[0].value(),cols[1].value(),cols[2].value()]
    if min(result)==0:
      key=key_map[int(rows.index(r))][int(result.index(0))]
      r.value(1) # manages key keept pressed
      return(key)
    r.value(1)

# Start the main loop
print("--- Ready to get user inputs ---")
while True:
    key=Keypad3x4Read(col_list, row_list)
    if key != None:
      print("You pressed: "+key)
      utime.sleep(0.3) # gives user enoght time to release without having double inputs