Manual Arduino
Manual Arduino
a - Siren light
void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
delay(200);
digitalWrite(12, LOW);
}
Siren Light
Program 1.b - Siren buzzer
void setup()
{
}
void loop()
{
digitalWrite(9, HIGH);
tone(9, 440 * pow(2.0, (constrain(int(map(300, 0, 1023, 36, 84)), 35, 127) - 57) / 12.0), 1000);
digitalWrite(9, LOW);
tone(9, 440 * pow(2.0, (constrain(int(map(200, 0, 1023, 36, 84)), 35, 127) - 57) / 12.0), 1000);
}
Siren Buzzer
Program 1.c- Siren light buzzer assessment
void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(13, HIGH);
tone(9, 440 * pow(2.0, (constrain(int(map(300, 0, 1023, 36, 84)), 35, 127) - 57) / 12.0), 1000);
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print("Hello World");
delay(1000);
}
void loop()
{
a = random(100);
b = random(100);
z = calculate(a,b);
//Adding 2 Numbers
//Write Values to Serial Monitor
Serial.print(a);
Serial.print(" + ");
Serial.print(b);
Serial.print(" = ");
Serial.println(z);
delay(1000);
}
float calculate(int x, int y)
{
return (x + y);
}
void setup()
{
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT);
void loop()
{
if (buttonState != lastButtonState) {
lastButtonState = buttonState;
if (buttonState == LOW) {
ledState = (ledState == HIGH) ? LOW: HIGH;
digitalWrite(LED_PIN, ledState);
}
}
}
https://www.tinkercad.com/things/7EShjOz7FMF-mighty-robo/editel?tenant=circuits
Program 5 - Controlling LED Blinks with variable resistance.
int potPin = 2; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup()
{
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}
void loop()
{
val = analogRead(potPin); // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(val); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // stop the program for some time
}
Program 6 - Dimmer.
const int ledPin = 9; // the pin that the LED is attached to
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
byte brightness; // check if data has been sent from the computer:
if (Serial.available()) {
analogWrite(ledPin, brightness);
}
}
int i,j,k;
void setup() {
String s2="",s4="",s5="";
// set up the LCD's number of columns and rows:
lcd.clear();
lcd.begin(16, 2);
// Print a message to the LCD.
for(i=0;i<=s1.length();i++){
s2+=s1[i];
lcd.print(s2);
delay(300);
lcd.clear();
for(i=0;i<=s1.length();i++){
lcd.clear();
s2="";
for(j=i;j<s1.length();j++){
s2+=s1[j];
}
lcd.print(s2);
delay(300);
}
lcd.clear();
lcd.print(s3);
delay(800);
// Print a message to the LCD.
for(k=0;k<3;k++){
for(i=0;i<=s3.length();i++){
lcd.clear();
s2="";
for(j=i;j<s3.length();j++){
s2+=s3[j];
}
lcd.print(s2);
delay(300);
}
}
setup();
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
// lcd.print(millis() / 1000);
}
void setup() {
//This function gets called when the Arduino starts
Serial.begin(115200);
//This code sets up the Serial port at 115200 baud rate
}
void loop() {
//This function loops while the arduino is powered
int val; //Create an integer variable
val=analogRead(0);
//Read the analog port 0 and store the value in val
Serial.println(val);
//Print the value to the serial port
delay(1000);
//Wait one second before we do it again
}