Ctech reviewer
Coding coding
Fading code:
int led = 9;
int brightness = 0;
int fadeAmount = 5;
void setup()
{
pinMode(led, OUTPUT);
}
void loop()
{
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255)
{
fadeAmount = -fadeAmount;
delay(500);
}
}
Stop light
int stop = 2;
int ready = 4;
int go = 6;
void setup()
{
pinMode(stop, OUTPUT);
pinMode(ready, OUTPUT);
pinMode(go, OUTPUT);
}
void loop()
{
digitalWrite(stop, HIGH);
digitalWrite(ready, LOW);
digitalWrite(go, LOW);
delay (5000);
digitalWrite(ready, HIGH);
digitalWrite(stop, LOW);
digitalWrite(go, LOW);
delay (3000);
digitalWrite(go, HIGH);
digitalWrite(ready, LOW);
digitalWrite(stop, LOW);
delay (8000);
digitalWrite(ready, HIGH);
digitalWrite(go, LOW);
delay (8000);
}
Pushbutton 1
int pushbutton1 = 13;
int led = 2;
void setup()
{
pinMode(pushbutton1, INPUT);
digitalWrite(pushbutton1, HIGH);
pinMode(led, OUTPUT);
}
void loop()
{
if(digitalRead(pushbutton1) == LOW)
{
digitalWrite(led, HIGH);
}
else
{
digitalWrite(led, LOW);
}
}
Pushbutton3
int pushbutton1 = 13; void loop()
int pushbutton2 = 12; {
int pushbutton3 = 11; if(digitalRead(pushbutton1) == LOW)
int led1 = 4; {
int led2 = 3; digitalWrite(led1,HIGH);
int led3 = 2; }
else
void setup() {
{ digitalWrite(led1,LOW);
pinMode(pushbutton1, INPUT); }
digitalWrite(pushbutton1, HIGH); {
pinMode(pushbutton2, INPUT); if(digitalRead(pushbutton2) == LOW)
digitalWrite(pushbutton2, HIGH); {
pinMode(pushbutton3, INPUT); digitalWrite(led2,HIGH);
digitalWrite(pushbutton3, HIGH); }
else
pinMode(led1,OUTPUT); {
pinMode(led2,OUTPUT); digitalWrite(led2,LOW);
pinMode(led3,OUTPUT); }
} {
if(digitalRead(pushbutton3) == LOW)
{
digitalWrite(led3,HIGH);
}
else
{
digitalWrite(led3,LOW);
}
}}}
Sensor shit
Evolution of sensing technologies:
- Shakey
o First mobile robot capable of any level of reasoning about its surroundings
o Built in 1970 by Stanford Research Institute (now SRI International) in California
o It combined multiple sensor inputs including TV cameras, laser range-finders, and ‘bump’
sensors to navigate
- WABOT-1
o Created in Japan by Waseda University in 1972
o World’s full-scale humanoid robot
o Could grip and transport objects with its hands using tactile sensors
- Silver Arm
o Designed by David Silver in 1974
o Capable of fine movements that replicated human hands with feedback provided by touch
and pressure sensors
- ASIMO
o Created out of Honda’s humanoid project in 2000
o Could communicate with humans, and recognize faces, environments, voices, and postures
Real time application of sensors
Autopilot System in aircrafts – almost all civilian and military aircrafts have Automatic Flight Control
System or Autopilot
- Consists of several sensors for various tasks like speed control, height, position, doors, obstacle,
fuel, maneuvering, etc
Sensors
(position, height, speed, Computer Output
temp., location)
What is a sensor?
- An input device which provides an output (signal) with respect to a specific physical quantity (input)
- Simplest ex.: Light Dependent Resistor (LDR)
o A device whose resistance varies according to intensity of light it is subjected to.
o When light more = resistance very less; when light less = resistance very high
Classifications of Sensors
- Classification 1
o Active sensors – require an external excitation signal or a power signal
o Passive sensors – do not require any external power signal, directly generates output
response
- Classification 2
o Based on the means of detection used in the sensor – ex. Electric, Biological, Chem., etc.
- Classification 3
o Based on conversion phenomenon i.e. the input and the output
o Some common: Photoelectric, Thermoelectric, Electrochemical, Electromagnetic
- Classification 4
o Analog Sensors – produce an analog output i.e. a continuous output signal with respect to
the quantity being measured
o Digital sensors – works with discrete or digital data. Data in these sensors, which is used for
conversion and transmission, is digital in nature
Idk what these are (unfiinshred)
- Sound and Vision
o Vision sensing
o Can be based on technologies such as: traditional camera & sonar and laser
o Light Detection and Ranging (LIDAR) systems are also popular choices for robot vision
It bounces light off nearby surfaces to create a 3D map of the world around it
o Audio sensors based on multiple microphones can be deployed to determine the
direction and intensity of a person’s voice or sound-based commands
- Touch
o Tactile Senor
Different types of sensors
- Temperature sensor
o Senses temperature and changes in temperature
o Changes in temperature can correspond to change in its physical property like resistance
or voltage
o Types: Temperature Sensor ICs, Thermistors. Thermocouples, Resistive Temperature
Devices (RTD)
- Proximity Sensor
o A non-contact sensor that detects the presence of an object when it enters the sensor’s
field
o Types: sound, light, infrared radiation, or electromagnetic fields
o Used: in phones, recycling plants, self-driving cars, anti-aircraft systems, and assembly
lines
- Infrared Sensor (IR Sensor)
o Light based sensor that are used in various applications like Proximity and Object
Detection
o Types:
Transmissive – IR Transmitter and IR Detector are positioned facing each other
so that when an object passes between, the sensor detects the object
Reflective – Transmitter and detector are positioned adjacent to each other
facing the object.
o Used: phones, robots, industrial assembly, automobiles
- Ultrasonic sensor
o Non-contact type device that can be used to measure distance as well as velocity of an
object
o Works based on the properties of the sound waves with frequency greater than human
audible range
- Light Sensor
o Device or circuit that detects the intensity of the light incident on it
o Types: Photo Diodes, Photo Transistors
o Called Photoelectric Devices
o They convert light energy to electrical energy
o Can detect visible light, ultraviolet light, and infrared light, etc.
- Smoke Sensor
o Smoke sensing device that indicates fire
o Common in homes, offices, schools, and industries
- Touch Sensor
o Detects physical touch or proximity
o Are more sensitive than buttons and switches
o Used in phones and laptops
o It detects the change in capacitance without the physical contact but when the finger is
placed slightly near to the sensor
o Different types: resistive, capacitive, piezo; most common is capacitive touch sensor
- Color sensor
o Device that senses or detects colors
o It emits light and analyzes the reflected light from the object in order to determine its
color
- Humidity sensor
o measures humidity in its environment and converts its findings to a corresponding
electrical signal
o Types:
Relative Humidity Sensor – measures temperature in order to determine
relative humidity
Absolute Humidity Sensor – measures humidity without reference to
temperature
- Tilt sensor
o Consists of a rolling ball with a conductive plate beneath
o When the sensor gets power, the rolling ball falls to the bottom of the sensor to form an
electrical connection
- Sound sensor
o Works similarly to our ears
o Has a diaphragm that converts vibration into signals
o Inside: in-built capacitive microphone, peak detector, and an amplifier
Pushbutton terms:
Serial Monitor – used for communication between the Arduino board and a computer or other
devices
Switch – electrical device having two states, on or off (open or close)
pbValue – a variable that will be used to hold the value that the tact switch will send to the
microcontroller unit
pinMode – a function that prepares all the pins used in the microcontroller
digitalWrite – sets the desired pin to maximum voltage and turns it on or off
Void loop – makes your code repeat over and over again
Void setup – first function to be executed in the sketch and it’s only executed once
[Link] – sets daya rate in bits per second for serial data transmission
ideal impedence when open for a switch: infinite; ideal impedence when close for a switch:
zero