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);
} 

Arduino Tutorials – Lesson 35 – Vibration Sensor on Arduino UNO

Creating Vibration Sensor program using Arduino UNO

Required Components

  1. Arduino Uno Board _1 no
  2. Vibration Sensor _1 no
  3. USB Cable _1 no
  4. Connecting Wires _1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Arduino UNO 7th pin to the Vibration Sensor DO pin.
  3. Connect the Arduino UNO 5V, GND to the Vibration Sensor VCC, GND.
  4. The LED 13th pin is Default.
  5. Connect the ground connection respectively.
  6. Check the Arduino program.
  7. Check the circuit connections.
  8. Run the Arduino program.

Arduino Program

int vib_pin=7;
int led_pin=13;

void setup() 
{
  pinMode(vib_pin,INPUT);
  pinMode(led_pin,OUTPUT);
  Serial.begin(9600);
}

void loop() 
{
  int val;
  long measurement =vibration();
  delay(50);
  Serial.println(measurement);
  if (measurement > 50){
    digitalWrite(led_pin, HIGH);
  }
  else{
    digitalWrite(led_pin, LOW); 
  }
}
 
long vibration()
{
  long measurement=pulseIn (vib_pin, HIGH);  
  return measurement;
}

Usage

  1. Food & Beverage
  2. Water & Waste water
  3. Oil & Gas
  4. Automotive

Arduino Tutorials – Lesson 34 – OLED Display Using Arduino UNO

To give the input (Numbers) to Serial Monitor and get the output in OLED Display.

Required Components

  1. OLED Display -1 no
  2. Arduino UNO Board -1 no
  3. USB Cable -1 no
  4. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect OLED Display gnd & VCC to the Arduino UNO Board gnd & 5V.
  3. Connect Arduino pin A4 & A5 to the OLED Display SDA & SCL.
  4. Check the Arduino program.
  5. Check the circuit connections.
  6. Run the Arduino program.

Arduino Program

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display(-1);

void setup()   
{                
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  
}

void loop() 
{
  if (Serial.available() > 0) 
  {   
    String a = Serial.readString();      
    display.clearDisplay();
    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.setCursor(10,10);
    display.println(a);
    display.display();
    delay(2000);
    Serial.print("Number received: ");
    Serial.println(a);   
  } 
}

Usage

  1. TVs
  2. Cellphone screens
  3. Computer screens
  4. Keyboards
  5. Lights
  6. Portable device displays

Arduino Tutorials – பாடம் 34 – OLED Display Using Arduino UNO

Serial Monitor-ல்  Input (எண்கள்) கொடுத்து , Output ஐ OLED டிஸ்ப்ளேயில் பெறுதல்.

Required Components

  1. OLED Display -1 no
  2. Arduino UNO Board -1 no
  3. USB Cable -1 no
  4. Connecting wires -1 set

Circuit

Steps

  1. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. OLED Display gnd & VCC ஐ Arduino UNO Board gnd & 5V உடன் இணைக்க வேண்டும்.
  3. Arduino UNO Board இன் A4 & A5 ஐ OLED Display SDA & SCL உடன் இணைக்க வேண்டும்.
  4. Arduino program ஐ சரி பார்க்க வேண்டும்.
  5. மின்சுற்றை சரி பார்க்க வேண்டும்.
  6. Arduino program ஐ ரன் செய்ய வேண்டும்.

Arduino Program

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display(-1);

void setup()   
{                
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  
}

void loop() 
{
  if (Serial.available() > 0) 
  {   
    String a = Serial.readString();      
    display.clearDisplay();
    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.setCursor(10,10);
    display.println(a);
    display.display();
    delay(2000);
    Serial.print("Number received: ");
    Serial.println(a);   
  } 
}

Usage

  1. டி.வி. (TVs)
  2. செல்போன் திரைகள் (Cellphone screens)
  3. கணினித் திரைகள் (Computer screens)
  4. விசைப்பலகைகள் (Keyboards)
  5. விளக்குகள் (Lights)
  6. சிறிய சாதன காட்சிகள் (Portable device displays)

Arduino Tutorials – பாடம் 33 – DF Player mini using Arduino MEGA2560

DF Player mini ஐ Arduino Uno Board ஐ பயன்படுத்தி சோதனை செய்வது.

Required Components

  1. DF Player mini -1 no
  2. Data Cable -1 no
  3. Connecting Wires -1 set
  4. Arduino Uno -1 no
  5. Speaker -1 no
  6. Resistor 1000ohm -1 no

Circuit

Steps

  1. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. Arduino Uno Boardன் +5V மற்றும் ground சப்ளையை DF Player Mini VCC மற்றும் GND உடன் இணைக்க வேண்டும்.
  3. Resistor ன் ஒரு முனையை DF Player Mini RX மற்றும் Resistor ன் மறு முனையை Arduino Uno Board 1 அல்லது TX உடன் இணைக்க வேண்டும்.
  4. Resistor ன் ஒரு முனையை DF Player Mini RX மற்றும் Resistor ன் மறு முனையை Arduino Uno Board 1 அல்லது TX உடன் இணைக்க வேண்டும்.
  5. மற்றொரு Resistor ன் ஒரு முனையை DF Player Mini TX மற்றும் Resistor ன் மறு முனையை Arduino Uno Board 0 அல்லது RX உடன் இணைக்க வேண்டும்.
  6. DF Player Mini SPK-1 & SPK-2 ஐ Speker உடன் இணைக்க வேண்டும்.
  7. Arduino program ஐ சரி பார்க்க வேண்டும்.
  8. மின்சுற்றை சரி பார்க்க வேண்டும்.
  9. Arduino program ஐ ரன் செய்ய வேண்டும்.

Arduino Program

#include "SoftwareSerial.h"
#include <DFMiniMp3.h> 
#define DEBUG 0
class Mp3Notify
{
public:
 static void OnError(uint16_t errorCode)
 {
  Serial.println();
  Serial.print("Com Error ");
  Serial.println(errorCode);
 }
 static void OnPlayFinished(uint16_t track)
 {
  Serial.print("Play finished for #");
  Serial.println(track);
 }
 static void OnCardOnline(uint16_t code)
 {
  Serial.println("Card online ");
 }
 static void OnCardInserted(uint16_t code)
 {
  Serial.println("Card inserted ");
 }
 static void OnCardRemoved(uint16_t code)
 {
  Serial.println("Card removed ");
 }
};
SoftwareSerial secondarySerial(10, 11); 
DFMiniMp3<SoftwareSerial, Mp3Notify> mp3(secondarySerial);
const int LDRpin = A0; 
const int LEDpin = 13; 
int Song=1; 
int ldrStatus;
boolean onStatus = true;
boolean takeLowTime;
long unsigned int timeoutTimer = 0, resetCount = 0;
long unsigned int pause = 2000;

void setup()
{
 Serial.begin(115200);
 if (DEBUG) Serial.println("initializing...");
 pinMode(LDRpin, INPUT); 
 pinMode(LEDpin, OUTPUT);
 mp3.begin();
 mp3.reset();
 uint16_t volume = mp3.getVolume();
 Serial.print("volume ");
 Serial.println(volume);
 mp3.setVolume(20);
 uint16_t count = mp3.getTotalTrackCount();
 Serial.print("files ");
 Serial.println(count);
 uint16_t mode = mp3.getPlaybackMode();
 Serial.print("playback mode ");
 Serial.println(mode);
 if (DEBUG) Serial.println("starting...");
 mp3.playFolderTrack(6, Song);
}

void loop()
{
 ldrStatus = analogRead(LDRpin);
 if (ldrStatus >=300)
  {
    digitalWrite(LEDpin, HIGH);
    mp3.start();
    onStatus = true;
  }
 else 
  {
    digitalWrite(LEDpin, LOW);
    mp3.pause();
  }

 mp3.loop(); 
}

Usage

  1. தீ எச்சரிக்கை குரல் எழுப்புதல் (Fire alarm voice prompts).
  2. கார் வழிசெலுத்தல் குரல் ஒளிபரப்பு (Car navigation voice broadcast).
  3. ரயில் நிலையம், பஸ் பாதுகாப்பு ஆய்வு குரல் எழுப்புதல் (Railway station, bus safety inspection voice prompts).
  4. மின்சாரம், தகவல் தொடர்பு, நிதி வணிக மண்டபக் குரல் எழுப்புதல் (Electricity, communications, financial business hall voice prompts).

Arduino Tutorials – பாடம் 32 – L298N Motor Driver with Node MCU

2 DC மோட்டார்களை  NodeMCU ஐ உபயோகப்படுத்தி கட்டுப்படுத்துவது.

Required Components

  1. Node MCU -1 no
  2. L298N Motor Driver -1 no
  3. 9V Battery -1 no
  4. 5V DC Motor -2 no
  5. Motor wheel -2 no
  6. Cable -1 no
  7. Jumper Wires -7 no

Circuit

Steps

  1. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. L298N Motor Driver உடன் 5V Battery ஐ கவனமாக இணைக்க வேண்டும்.
  3. L298N Motor Driver ENA, IN1, IN2, IN3, IN4, ENB பின்களை Node MCU D2, D0, D1, D7, D6, D5 உடன் இணைக்க வேண்டும்.
  4. L298N Motor Driver gnd உடன் Node MCU gnd ஐ இணைக்க வேண்டும்.
  5. L298N Motor Driver OUTPUT பின்களுடன் DC மோட்டார் OUTPUT பின்களை இணைக்க வேண்டும்.
  6. Node MCU உடன் Power ஐ இணைக்க வேண்டும்.
  7. Arduino program ஐ சரி பார்க்க வேண்டும்.
  8. மின்சுற்றை சரி பார்க்க வேண்டும்.
  9. Arduino program ஐ ரன் செய்ய வேண்டும்.

Arduino Program

#include <ESP8266WiFi.h>
const char* ssid = "*****";
const char* password = "*********";
int motor1pin1 = 16; //D0
int motor1pin2 = 5; //D1
int enPin1 = 4; //D2
int motor2pin1 = 13; //D7
int motor2pin2 = 12; //D6
int enPin2 = 14;//D5
WiFiServer server(80);

void setup() 
{
  Serial.begin(115200);
  delay(10);
  pinMode(motor1pin1, OUTPUT);
  pinMode(motor1pin2, OUTPUT);
  pinMode(enPin1, OUTPUT);
  digitalWrite(enPin1, HIGH);
  pinMode(motor2pin1, OUTPUT);
  pinMode(motor2pin2, OUTPUT);
  pinMode(enPin2, OUTPUT);
  digitalWrite(enPin2, HIGH);
  
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) 
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  server.begin();
  Serial.println("Server started");
  Serial.print("Use this URL to connect: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");
}

void loop() 
{
  WiFiClient client = server.available();
  if (!client) 
  {
    return;
  }
  Serial.println("new client");
  while(!client.available())
  {
    delay(1);
  }
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();
  int value,value1 = LOW,value2 = LOW,value3 = LOW,value4 = LOW;
  if (request.indexOf("/MotorForward") != -1)
  {
    digitalWrite(motor1pin1, HIGH);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, HIGH);
    digitalWrite(motor2pin2, LOW);
    delay(1000);
    value1 = HIGH;
    value2 = LOW;
    value3 = HIGH;
    value4 = LOW;
  }
  if (request.indexOf("/MotorBackward") != -1)
  {
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, HIGH);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, HIGH);
    delay(1000);
    value1 = LOW;
    value2 = HIGH;
    value3 = LOW;
    value4 = HIGH;
  }
  if (request.indexOf("/MotorLeft") != -1)
  {
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, HIGH);
    digitalWrite(motor2pin1, HIGH);
    digitalWrite(motor2pin2, LOW);
    delay(1000);
    value1 = LOW;
    value2 = HIGH;
    value3 = HIGH;
    value4 = LOW;
  }
  if (request.indexOf("/MotorRight") != -1)
  {
    digitalWrite(motor1pin1, HIGH);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, HIGH);
    delay(1000);
    value1 = HIGH;
    value2 = LOW;
    value3 = LOW;
    value4 = HIGH;
  }
  if (request.indexOf("/MotorStop") != -1)
  {
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, LOW);
    digitalWrite(motor2pin1, LOW);
    digitalWrite(motor2pin2, LOW);
    delay(1000);
    value1 = LOW;
    value2 = LOW;
    value3 = LOW;
    value4 = LOW;
  }
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");
  client.print("motor is now: ");
  
  if(value1 == HIGH && value2 == LOW && value3 == HIGH && value4 == LOW ) {
    client.print("Forward");
  }
  else if(value1 == LOW && value2 == HIGH && value3 == LOW && value4 == HIGH  ) {
    client.print("Backward");
  }
  else if(value1 == LOW && value2 == HIGH && value3 == HIGH && value4 == LOW  ) {
    client.print("Left");
  }
  else if(value1 == HIGH && value2 == LOW && value3 == LOW && value4 == HIGH  ) {
    client.print("Right");
  }
  else if(value1 == LOW && value2 == LOW && value3 == LOW && value4 == LOW  ) {
    client.print("Stop");
  }
  client.println("<br><br>");
  client.println("<a href=\"/MotorForward\"\"><button>Forward </button></a>");
  client.println("<a href=\"/MotorBackward\"\"><button>Backward </button></a><br />");
  client.println("<a href=\"/MotorLeft\"\"><button>Left </button></a>");
  client.println("<a href=\"/MotorRight\"\"><button>Right </button></a><br />");
  client.println("<a href=\"/MotorStop\"\"><button>Stop </button></a>");
  client.println("</html>");
  delay(1);
  Serial.println("Client disonnected");
  Serial.println("");
}

Usage

  1. நேரோட்ட மின்சார இயக்கி(Drive DC motors)
  2. படிநிலை இயக்கி(Drive Stepping motors)
  3. ரோபாட்டிக்ஸ்(In Robotics)

Projects

  1. திவா ரோபோட் (Diwa Robot)