Movatterモバイル変換


[0]ホーム

URL:


PPTX, PDF6 views

Understanding Arduino Uno Code(simple coding).pptx

This presentation all about Arduino UNO coding and simple explanation about codes and simple work through to start new robotic project

Embed presentation

Download to read offline
UNDERSTANDINGARDUINO UNO CODELEARN HOW TO READ AND WRITE BASIC ARDUINOPROGRAMS
OBJECTIVES• Understand the structure of Arduino code• Learn what setup() and loop() do• Use functions like pinMode(), digitalWrite(), and digitalRead()• Build and understand a simple blinking LED circuit• Understand how analog sensors and serial monitor work• Explore the use of piezo buzzers and PWM output• Learn how to properly wire and connect components to ArduinoUno2
WHAT IS ARDUINOCODE?• CALLED A "SKETCH"• WRITTEN IN SIMPLIFIED C/C++• TWO MAIN PARTS:VOID SETUP()VOID LOOP()
STRUCTURE OF ARDUINO CODEvoid setup() {// Runs once when the Arduino starts}void loop() {// Repeats forever}setup() = initializationloop() = main program4
EXAMPLE: BLINKING AN LEDvoid setup() {pinMode(13, OUTPUT);}void loop() {digitalWrite(13, HIGH);delay(1000);digitalWrite(13, LOW);delay(1000);}5
CODE EXPLANATION• pinMode(13, OUTPUT) - sets pin 13 to OUTPUT mode• digitalWrite(13, HIGH) - turns LED ON• delay(1000) - waits for 1 second• digitalWrite(13, LOW) - turns LED OFF6
COMMON ARDUINO FUNCTIONS7Function PurposepinMode() Set pin as input or outputdigitalWrite() Turn pin HIGH or LOWdigitalRead() Read signal from pinanalogRead() Read analog sensor valueanalogWrite() Output PWM signal (0–255)delay() Pause the program
PROJECT: BUTTON-CONTROLLED LEDWiring Instructions:• Connect one leg of the button to digital pin 2• Connect the other leg to GND• Add an LED: longer leg (anode) to pin 13, shorter leg (cathode) through a 220Ωresistor to GNDCode:8void setup() {pinMode(2, INPUT_PULLUP);pinMode(13, OUTPUT);}void loop() {int buttonState = digitalRead(2);if (buttonState == LOW) {digitalWrite(13, HIGH);}else {digitalWrite(13, LOW);}}
EXPLANATION OF BUTTON CODE• INPUT_PULLUP uses internal resistor• digitalRead(2) reads if button is pressed• LOW = button pressed• digitalWrite(13, HIGH) turns LED ON9
ANALOG INPUT: READING A LIGHTSENSOR (LDR)• Connect one leg of the LDR to 5V• Connect the other leg to analog pin A0• From A0, also connect a 10kΩ resistor to GND• This forms a voltage dividerCode sample:10int ldr = A0;void loop() {int value = analogRead(ldr);Serial.println(value);delay(500);}• Can be used to control brightness, automatic lights, etc.
USING SERIAL MONITOR• Serial.begin(9600) starts communication• Serial.print() / Serial.println() sends data toyour PC• Open Serial Monitor in Arduino IDE to seeoutput• Useful for testing and debugging11
PLAYING SOUND WITH A PIEZOBUZZERWiring Instructions:• Connect positive leg of the buzzer to pin 8• Connect negative leg to GNDSample Code:12int buzzer = 8;void loop() {tone(buzzer, 262, 500);delay(1000);noTone(buzzer);}• Can add arrays of notes and durations for full songs
Using PWM with analogWrite()Wiring Example (for dimming LED):• Connect LED anode (long leg) to pin 9 (~PWM pin)• Connect cathode (short leg) through 220Ω resistor to GNDSample Code:13analogWrite(9, 128); // 50% brightness• Can dim LEDs or control motor speed
PRACTICEQUESTIONS• What does setup() do?• How is loop() different?• What happens if you removedelay()?• What is the value range ofanalogRead()?• How do you play soundusing a buzzer?• How would you wire an LDRto A0 properly?
SUMMARY1.Arduino programs are simple but powerful2.setup() and loop() are the core of every sketch3.Use digital and analog functions for inputs and outputs4.Serial Monitor helps you test and debug5.You can even add sound and control brightness with PWM6.Proper wiring is important to avoid damage and errors15

Recommended

PPTX
Programming with arduino
PPTX
Arduino cic3
PDF
Arduino-workshop.computer engineering.pdf
PPTX
Arduino UNO Introduction for Beginers.pptx
PPTX
Arduino Day 1 Presentation
PPT
Physical prototyping lab2-analog_digital
PPT
Physical prototyping lab2-analog_digital
PDF
02 Sensors and Actuators Understand .pdf
PPT
01 Intro to the Arduino and it's basics.ppt
PDF
Intro arduino English
PPTX
Arduino programming
PPTX
Introduction to Arduino Microcontroller
PPTX
Microcontroller_basics_lesson1_2019 (1).pptx
PPTX
Ch_2_8,9,10.pptx
PPTX
PPTX
Getting started with arduino workshop
PPTX
IOT-UNIT 3.pptxaaaasasasasasasaasasasasas
PPTX
Introduction to arduino Programming with
PPTX
Arduino slides
PPTX
Arduino Workshop Slides
PDF
Introduction to Arduino Programming
PPTX
Aurdino presentation
PPTX
INTRODUCTION TO ARDUINO and sensors for arduino.pptx
PPTX
Arduino Slides With Neopixels
PPT
13223971.ppt
PPT
Arduino_CSE ece ppt for working and principal of arduino.ppt
PPTX
firewall Selection in production life pptx
PPTX
MECCA Empire – Hotel Shuttle System for the 2026 FIFA World Cup
 

More Related Content

PPTX
Programming with arduino
PPTX
Arduino cic3
PDF
Arduino-workshop.computer engineering.pdf
PPTX
Arduino UNO Introduction for Beginers.pptx
PPTX
Arduino Day 1 Presentation
PPT
Physical prototyping lab2-analog_digital
PPT
Physical prototyping lab2-analog_digital
PDF
02 Sensors and Actuators Understand .pdf
Programming with arduino
Arduino cic3
Arduino-workshop.computer engineering.pdf
Arduino UNO Introduction for Beginers.pptx
Arduino Day 1 Presentation
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
02 Sensors and Actuators Understand .pdf

Similar to Understanding Arduino Uno Code(simple coding).pptx

PPT
01 Intro to the Arduino and it's basics.ppt
PDF
Intro arduino English
PPTX
Arduino programming
PPTX
Introduction to Arduino Microcontroller
PPTX
Microcontroller_basics_lesson1_2019 (1).pptx
PPTX
Ch_2_8,9,10.pptx
PPTX
PPTX
Getting started with arduino workshop
PPTX
IOT-UNIT 3.pptxaaaasasasasasasaasasasasas
PPTX
Introduction to arduino Programming with
PPTX
Arduino slides
PPTX
Arduino Workshop Slides
PDF
Introduction to Arduino Programming
PPTX
Aurdino presentation
PPTX
INTRODUCTION TO ARDUINO and sensors for arduino.pptx
PPTX
Arduino Slides With Neopixels
PPT
13223971.ppt
PPT
Arduino_CSE ece ppt for working and principal of arduino.ppt
01 Intro to the Arduino and it's basics.ppt
Intro arduino English
Arduino programming
Introduction to Arduino Microcontroller
Microcontroller_basics_lesson1_2019 (1).pptx
Ch_2_8,9,10.pptx
Getting started with arduino workshop
IOT-UNIT 3.pptxaaaasasasasasasaasasasasas
Introduction to arduino Programming with
Arduino slides
Arduino Workshop Slides
Introduction to Arduino Programming
Aurdino presentation
INTRODUCTION TO ARDUINO and sensors for arduino.pptx
Arduino Slides With Neopixels
13223971.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt

Recently uploaded

PPTX
firewall Selection in production life pptx
PPTX
MECCA Empire – Hotel Shuttle System for the 2026 FIFA World Cup
 
PPT
63490613-Boiler-Tube-Leakage-analysis-symptoms-causes.ppt
PPTX
Revolutionizing Facilities Management with MaintWiz — AI CMMS for Smart FMaaS
PPTX
Shutdown Maintenance Explained — Full Plant Turnaround & Best Practices with ...
PPTX
Track & Monitor Preventive Maintenance — Best Practices with MaintWiz CMMS
PDF
AI-Driven CTI for Business: Emerging Threats, Attack Strategies, and Defensiv...
PDF
Advanced Intrusion Detection and Classification using Transfer Learning with ...
PPTX
Plant Performance Strategies: Enhanced Reliability & Operational Efficiency w...
PPTX
علي نفط.pptx هندسة النفط هندسة النفط والغاز
PPTX
22304_BCO_CO3_LO4_PPT MSBTE Building construction.pptx
PPTX
How to Use Mobile CMMS to Improve Maintenance Operations & Field Productivity
PPTX
Step-by-step guide to designing standard a microbiology laboratory in pharmac...
PPTX
Data Science with R Final yrUnit II.pptx
PPT
new Introduction to PACS.ppt Picture Archieving and communication and medicine
PPTX
Unit 1 Introduction to Information Technology in Business.pptx
PPTX
TPM Metrics & Measurement: Drive Performance Excellence with TPM | MaintWiz
PPTX
Salesforce Bulk Connector V1 and V2 Deep Dive!
PPTX
Natural Gas fundamentals and GRU for associated gas trap.pptx
PPTX
Emerging Trends and Research Frontiers in Chemical Engineering for Green and ...
firewall Selection in production life pptx
MECCA Empire – Hotel Shuttle System for the 2026 FIFA World Cup
 
63490613-Boiler-Tube-Leakage-analysis-symptoms-causes.ppt
Revolutionizing Facilities Management with MaintWiz — AI CMMS for Smart FMaaS
Shutdown Maintenance Explained — Full Plant Turnaround & Best Practices with ...
Track & Monitor Preventive Maintenance — Best Practices with MaintWiz CMMS
AI-Driven CTI for Business: Emerging Threats, Attack Strategies, and Defensiv...
Advanced Intrusion Detection and Classification using Transfer Learning with ...
Plant Performance Strategies: Enhanced Reliability & Operational Efficiency w...
علي نفط.pptx هندسة النفط هندسة النفط والغاز
22304_BCO_CO3_LO4_PPT MSBTE Building construction.pptx
How to Use Mobile CMMS to Improve Maintenance Operations & Field Productivity
Step-by-step guide to designing standard a microbiology laboratory in pharmac...
Data Science with R Final yrUnit II.pptx
new Introduction to PACS.ppt Picture Archieving and communication and medicine
Unit 1 Introduction to Information Technology in Business.pptx
TPM Metrics & Measurement: Drive Performance Excellence with TPM | MaintWiz
Salesforce Bulk Connector V1 and V2 Deep Dive!
Natural Gas fundamentals and GRU for associated gas trap.pptx
Emerging Trends and Research Frontiers in Chemical Engineering for Green and ...

Understanding Arduino Uno Code(simple coding).pptx

  • 1.
    UNDERSTANDINGARDUINO UNO CODELEARNHOW TO READ AND WRITE BASIC ARDUINOPROGRAMS
  • 2.
    OBJECTIVES• Understand thestructure of Arduino code• Learn what setup() and loop() do• Use functions like pinMode(), digitalWrite(), and digitalRead()• Build and understand a simple blinking LED circuit• Understand how analog sensors and serial monitor work• Explore the use of piezo buzzers and PWM output• Learn how to properly wire and connect components to ArduinoUno2
  • 3.
    WHAT IS ARDUINOCODE?•CALLED A "SKETCH"• WRITTEN IN SIMPLIFIED C/C++• TWO MAIN PARTS:VOID SETUP()VOID LOOP()
  • 4.
    STRUCTURE OF ARDUINOCODEvoid setup() {// Runs once when the Arduino starts}void loop() {// Repeats forever}setup() = initializationloop() = main program4
  • 5.
    EXAMPLE: BLINKING ANLEDvoid setup() {pinMode(13, OUTPUT);}void loop() {digitalWrite(13, HIGH);delay(1000);digitalWrite(13, LOW);delay(1000);}5
  • 6.
    CODE EXPLANATION• pinMode(13,OUTPUT) - sets pin 13 to OUTPUT mode• digitalWrite(13, HIGH) - turns LED ON• delay(1000) - waits for 1 second• digitalWrite(13, LOW) - turns LED OFF6
  • 7.
    COMMON ARDUINO FUNCTIONS7FunctionPurposepinMode() Set pin as input or outputdigitalWrite() Turn pin HIGH or LOWdigitalRead() Read signal from pinanalogRead() Read analog sensor valueanalogWrite() Output PWM signal (0–255)delay() Pause the program
  • 8.
    PROJECT: BUTTON-CONTROLLED LEDWiringInstructions:• Connect one leg of the button to digital pin 2• Connect the other leg to GND• Add an LED: longer leg (anode) to pin 13, shorter leg (cathode) through a 220Ωresistor to GNDCode:8void setup() {pinMode(2, INPUT_PULLUP);pinMode(13, OUTPUT);}void loop() {int buttonState = digitalRead(2);if (buttonState == LOW) {digitalWrite(13, HIGH);}else {digitalWrite(13, LOW);}}
  • 9.
    EXPLANATION OF BUTTONCODE• INPUT_PULLUP uses internal resistor• digitalRead(2) reads if button is pressed• LOW = button pressed• digitalWrite(13, HIGH) turns LED ON9
  • 10.
    ANALOG INPUT: READINGA LIGHTSENSOR (LDR)• Connect one leg of the LDR to 5V• Connect the other leg to analog pin A0• From A0, also connect a 10kΩ resistor to GND• This forms a voltage dividerCode sample:10int ldr = A0;void loop() {int value = analogRead(ldr);Serial.println(value);delay(500);}• Can be used to control brightness, automatic lights, etc.
  • 11.
    USING SERIAL MONITOR•Serial.begin(9600) starts communication• Serial.print() / Serial.println() sends data toyour PC• Open Serial Monitor in Arduino IDE to seeoutput• Useful for testing and debugging11
  • 12.
    PLAYING SOUND WITHA PIEZOBUZZERWiring Instructions:• Connect positive leg of the buzzer to pin 8• Connect negative leg to GNDSample Code:12int buzzer = 8;void loop() {tone(buzzer, 262, 500);delay(1000);noTone(buzzer);}• Can add arrays of notes and durations for full songs
  • 13.
    Using PWM withanalogWrite()Wiring Example (for dimming LED):• Connect LED anode (long leg) to pin 9 (~PWM pin)• Connect cathode (short leg) through 220Ω resistor to GNDSample Code:13analogWrite(9, 128); // 50% brightness• Can dim LEDs or control motor speed
  • 14.
    PRACTICEQUESTIONS• What doessetup() do?• How is loop() different?• What happens if you removedelay()?• What is the value range ofanalogRead()?• How do you play soundusing a buzzer?• How would you wire an LDRto A0 properly?
  • 15.
    SUMMARY1.Arduino programs aresimple but powerful2.setup() and loop() are the core of every sketch3.Use digital and analog functions for inputs and outputs4.Serial Monitor helps you test and debug5.You can even add sound and control brightness with PWM6.Proper wiring is important to avoid damage and errors15

[8]ページ先頭

©2009-2025 Movatter.jp