Professional Documents
Culture Documents
Learn Arduino With TinkerCad - Day 2 PDF
Learn Arduino With TinkerCad - Day 2 PDF
Learn Arduino With TinkerCad - Day 2 PDF
TinkerCad
Day 2
Mohd.Ruhul Ameen
ameensunny242@gmail.com
Mobile: +880 1521 300 804
Buzzer
void setup(){
pinMode(13, OUTPUT);
void loop(){
digitalWrite(13, HIGH);
digitalWrite(13, LOW);
}
tone();
Syntax
tone(pin, frequency)
https://www.arduino.cc/reference/en/language/functions/advanced-io/tone/
Play a Melody using the tone() function
void setup() {}
void setup() {
void loop() {
// to calculate the note duration, take one second divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / noteDurations[thisNote];
tone(8, melody[thisNote], noteDuration);
}
https://gist.githubusercontent.com/mikeputnam/2820675/raw/bbe995aa22826
a8fbbb6b56ccd56513f9db6cb00/pitches.h
https://github.com/ameenruhul/ArduinoBuzzer/blob/master/Arduino
HBDTone/ArduinoHBDTone.ino
Use Pin 9 Or change in the code
Home Work :
1) https://github.com/ameenruhul/AmarSonarBangla/blob/master/AmarSonarBangla.ino
2) https://github.com/munem-shahriar/Tone-RomjanerOiRojarSheshe-
Arduino/blob/master/RomjanerOiRojarShesheEloKhushirEid/RomjanerOiRojarShesheEloKhushi
rEid.ino
Pushbuttons
int buzzPin = 13;
int inputPin = 7;
void setup(){
Serial.begin(9600);
void loop(){
Serial.println(pushed);
digitalWrite(buzzPin, HIGH);
digitalWrite(buzzPin, LOW);
}
টাামওোকক ঃ ডমউডজকাে কীদোিক
Potentiometer
int sensorValue = 0;
void setup()
{
pinMode(A0, INPUT);
pinMode(9, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// read the value from the sensor
sensorValue = analogRead(A0);
Serial.println(sensorValue);
// turn the LED on
analogWrite(9, sensorValue);
}
টেিদরর জগৎ
Tmp36
2^10 = 1024
Arduino ADC (analog to digital converter) is 10 bit
Can Show values upto 0 - 1023
void loop()
{
int reading = analogRead(sensorPin);
}
H/W : LDR
আদোর উপডিডেদে এেইডি েন্ধ াদে যাদে
আদো না থাকদে এেইডি জ্বদে যাদে
Servo Motor
#include <Servo.h>
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in
variable 'pos'
delay(15); // waits 15ms for the servo to
reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in
variable 'pos'
delay(15); // waits 15ms for the servo to
reach the position
}
}