Exercise: Sketch 01
Learning points:
Each Arduino board must have 2 functions - setup() and loop().
void setup() initializes the Arduino board. It only runs once.
void loop() is the function that runs continuously.
Functions:
pinMode(pin_number, mode)
e.g. pinMode(13, OUTPUT);
digitalWrite(pin_number, mode)
e.g. digitalWrite(13, HIGH)
delay(time)
e.g. delay(1000) // delay 1000 msecs
Exercise: Sketch 02
Learning points:
An Arduino can accept analog and digital inputs. We are using a variable resistor in this circuit.
Functions:
analogRead(pin_number)
e.g. sensorValue = analogRead(sensorPin)
Exercise: Sketch 03
Learning points:
Putting "const" is like "final static" in Java.
The white LED has 3 pins for RGB, ranging from 0 to 767.
Functions:
for (x = 0; x < 768, x++)
{
function_A();
}
analogWrite(pin_number, int value)
e.g. analogWrite( RED_PIN, redIntensity)
Example: Sketch 04
Learning points:
Arrays in Processing
int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
Functions:
random(limit_value);
e.g. int index = random(8); // picks a number randomly from 0 to 7
Exercise: Sketch 05
Learning points:
Boolean logic using digital pins for input
Connect the pin of the pushbutton to GND and the other pin to a digital pin. Use a 10K resistor in between the pin of the pushbutton and the digital pin so that when the pushbutton is not pressed, the pin will read as "HIGH".
Functions:
A == B
A != B
A && B
A || B
!A
Exercise: Sketch 06
Learning points:
Using photoresistors
Functions:
map(initial lower bound, initial upper bound, ideal lower bound, ideal upper bound);
e.g. map(0, 1023, 0 , 255) // map values from 0 to 1023 to 0 to 255
constrain(range of values, lower bound, upper bound);
e.g. constrain(lightLevel, 0, 255)
Exercise: Sketch 07
Learning points:
Using temperature sensors
Do not connect the temperature sensor in the opposite direction (Vin to the GND pin of the temperature sensor)! The sensor heated up till over 260 degrees and I got burnt. Ouch..
Serial transmission
Functions:
Serial.being(baud rate)
e.g. Serial.begin(9600)
Serial.print(string or variable)
Exercise: Sketch 08
Learning points:
Using servos
Importing libraries
Functions:
#import <
Exercise: Sketch 09
Learning points:
Using the flex sensor
Functions:
flexposition = analogRead(filexpin);
Packers And Movers Hyderabad to Agra
ReplyDeletePackers And Movers Hyderabad to Meerut
Packers And Movers Hyderabad to Varanasi
Packers And Movers Hyderabad to Allahabad
Packers And Movers Hyderabad to Bareilly