1 of 26

Analog control

CDSID: lvishwan

1

LEVEL -1

2 of 26

Current is the rate at which electrons flow past a point in a complete electrical circuit. At its most basic, current = flow.

An ampere (AM-pir), or amp, is the international unit used for measuring current

Voltage is the pressure from an electrical circuit's power source that pushes charged electrons (current) through a conducting loop, enabling them to do work such as illuminating a light.

In brief, voltage = pressure, and it is measured in volts (V)

3 of 26

Voltage is either alternating current (ac) voltage or direct current (dc) voltage. Ways they differ:

Alternating current voltage (represented on a digital multimeter by

Direct current voltage (represented on a digital multimeter by

domestic house voltage= 220

common electronic appliances= 24 , 12, 5

4 of 26

Conductor: A conductor, or electrical conductor, is a substance or material that allows electricity to flow through it

Insulator: a substance that resists electricity

Semi conductor:A semiconductor is a substance whose resistivity lies between the conductors and insulators

Resistor:Resistor is defined as. A passive electrical component with two terminals that are used for either limiting or regulating the flow of electric current in electrical circuits(converts electrical to heat)

diode:A diode is a semiconductor device that essentially acts as a one-way switch for current. It allows current to flow easily in one direction, but severely restricts current from flowing in the opposite direction

PN diode-oneway

Zenor diode- filter

LED- emits light

potentio meter:

A potentiometer is a three-terminal resistor with a sliding or rotating contact that forms an adjustable voltage divider.[1] If only two terminals are used, one end and the wiper, it acts as a variable resistor or rheostat

Relay:

5 of 26

basic components:

relay-1

resistor 1k-5

resistor 2k-5

resistor 3k-5

PN diode-5

Zenor diode-5

RGB LED-2

LED-2

Raspberry pico-1

multimeter-1

6 of 26

AC to DC Converters are one of the most important elements in power electronics. This is because there are a lot of real-life applications that are based on these conversions. The electrical circuits that transform alternating current (AC) input into direct current (DC) output are known as AC-DC converters. They are used in power electronic applications where the power input a 50 Hz or 60 Hz sine-wave AC voltage that requires power conversion for a DC output.

The process of conversion of AC current to dc current is known as rectification. The rectifier converts the AC supply into the DC supply at the load end connection. Similarly, transformers are normally used to adjust the AC source to reduce the voltage level to have a better operation range for DC supply

7 of 26

DC – DC Converter Transformers are used in step-up or step-down converters. These transformers can be used in self-saturated or square wave driven applications and have input voltage ranges of 5V, 12V, 24V, and 48V and output Voltage up to 300 VDC

A transformer is an inductive electrical device for changing the voltage of alternating current.

A transformer consists of two magnetically coupled coils. Alternating current in one (called the "primary") creates a changing magnetic field which induces a current in the second coil (the "secondary")

8 of 26

12 V DC to 5V DC

7805 voltage regulator

cost 10 Rs

Z-diode cost 2 Rs

1K- resistor cost 1Rs

9 of 26

Resistors to use:

1k: 12 v to 5 v

2k: 24v to 5v

3k:48V to 5v

10 of 26

11 of 26

Micro controller

Microprocessor

12 of 26

Arduino:

  • micro controller
  • converts analog to digital
  • types: uno/nano/micro,......
  • C++ used
  • Auto start
  • External programing

Raspberry pi:

  • microprocessor
  • converts analog to digital
  • types: A,B,C,...
  • python used
  • boot required
  • Internal programing

13 of 26

Micro controller

-Arduino

-C++

14 of 26

Arduino:

IR program

c++:

#include<IRremote.h>

IRrecv irrecv(11);

decode_results results;

void setup()

{Serial.begin(9600);

irrecv.enableIRIn();

digitalWrite(13, HIGH);}

void loop(){

if (irrecv.decode(&results))

{Serial.println(results.value,HEX);

irrecv.resume();}

delay(100);

}

Arduino:

Connection

15 of 26

#include <IRremote.h>

const int RECV_PIN = 2;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()

{

Serial.begin(9600);

irrecv.enableIRIn();

irrecv.blink13(true);

}

void loop() {

if (irrecv.decode(&results)) {

if (results.decode_type == NEC) {

Serial.print("NEC: ");

} else if (results.decode_type == SONY) {

Serial.print("SONY: ");

} else if (results.decode_type == RC5) {

Serial.print("RC5: ");

} else if (results.decode_type == RC6) {

Serial.print("RC6: ");

} else if (results.decode_type == UNKNOWN) {

Serial.print("UNKNOWN: ");

}

Serial.println(results.value, HEX);

irrecv.resume();

}

}

16 of 26

#include <IRremote.h>

const byte IR_RECEIVE_PIN =2;

void setup()

{

Serial.begin(115200);

Serial.println("IR Receive test");

IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);

}

void loop()

{

if (IrReceiver.decode())

{

Serial.println(IrReceiver.decodedIRData.command, HEX);

IrReceiver.resume();

}

}

17 of 26

#include <IRremote.h>

IRsend irsend;

void setup() {}

void loop() {

irsend.sendRC5(0x1FC1, 32);

delay(5000);

}

18 of 26

Project1: universal remote conroller

19 of 26

LCD 16x2 with I2C

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()

{

lcd.init(); // initialize the lcd

lcd.backlight();

Serial.begin(9600);

}

void loop()

{

if (Serial.available()) {

delay(100);

lcd.clear();

while (Serial.available() > 0) {lcd.write(Serial.read());}

}

}

20 of 26

MULTI SERIAL (IR/bluetooth/lcd)

#include<IRremote.h>

#include <SoftwareSerial.h>

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

//ir- out=2

//bluetooth-rx=tx;tx=rx

//i2c-a4=sda;a5=scl

LiquidCrystal_I2C lcd(0x27,16,2);

SoftwareSerial blueseial(0, 1);

IRrecv irrecv(2);

decode_results results;

void setup()

{Serial.begin(9600);

blueseial.begin(9600);

irrecv.enableIRIn();

lcd.init();

lcd.backlight();

lcd.println("welcome");

}

void loop(){

if (irrecv.decode(&results))

{Serial.println(results.value,HEX);

blueseial.println(results.value,HEX);

lcd.clear();

lcd.println(results.value,HEX);

irrecv.resume();}

delay(100);

}

21 of 26

LED

what is LED

LED blink program with arduino

LED types:

single color LED

RGB LED

RGB LED STRIP

Addressable LED strip

22 of 26

RGB with pico

from picozero import RGBLED

from time import sleep

rgb = RGBLED(red = 1, green = 2, blue = 3)

rgb.color = (255, 100, 55)

23 of 26

RGB led strip with arduino

24 of 26

Bluetooth control

25 of 26

Wifi

import network

import socket

from time import sleep

from picozero import pico_temp_sensor, pico_led

import machine

ssid = 'Devil'

password = 'annyeo12'

def connect():

#Connect to WLAN

wlan = network.WLAN(network.STA_IF)

wlan.active(True)

wlan.connect(ssid, password)

while wlan.isconnected() == False:

print('Waiting for connection...')

sleep(1)

ip = wlan.ifconfig()[0]

print(f'Connected on {ip}')

return ip

def open_socket(ip):

# Open a socket

address = (ip, 80)

connection = socket.socket()

connection.bind(address)

connection.listen(1)

return connection

def webpage(temperature, state):

#Template HTML

html = f"""

<!DOCTYPE html>

<html>

<form action="./lighton">

<input type="submit" value="Light on" />

</form>

<form action="./lightoff">

<input type="submit" value="Light off" />

</form>

<p>LED is {state}</p>

<p>Temperature is {temperature}</p>

</body>

</html>

"""

return str(html)

def serve(connection):

state = 'OFF'

pico_led.off()

temperature = 0

while True:

client = connection.accept()[0]

request = client.recv(1024)

request = str(request)

try:

request = request.split()[1]

except IndexError:

pass

if request == '/lighton?':

pico_led.on()

state = 'ON'

elif request =='/lightoff?':

pico_led.off()

state = 'OFF'

temperature = pico_temp_sensor.temp

html = webpage(temperature, state)

client.send(html)

client.close()

try:

ip = connect()

connection = open_socket(ip)

serve(connection)

except KeyboardInterrupt:

machine.reset()

26 of 26

IOT

import network

import urequests

import machine

import time

led = machine.Pin("LED", machine.Pin.OUT)

wlan = network.WLAN(network.STA_IF)

wlan.active(True)

ssid = 'Devil'

password = 'annyeo12'

wlan.connect(ssid, password)

while True:

r = urequests.get("https://viswa.pythonanywhere.com")

response=r.text

if response=='1':led.on()

else:led.off()

time.sleep(1)