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

PDF
Arduino-workshop.computer engineering.pdf
PDF
02 Sensors and Actuators Understand .pdf
PPTX
Arduino UNO Introduction for Beginers.pptx
PPTX
Arduino Day 1 Presentation
PPTX
Programming with arduino
PPTX
Arduino cic3
PPT
Physical prototyping lab2-analog_digital
PPT
Physical prototyping lab2-analog_digital
PPTX
IOT-UNIT 3.pptxaaaasasasasasasaasasasasas
PPTX
INTRODUCTION TO ARDUINO and sensors for arduino.pptx
PPT
01 Intro to the Arduino and it's basics.ppt
PPTX
Arduino programming
PPTX
Arduino Slides With Neopixels
PPTX
Introduction to Arduino Microcontroller
PPTX
PPTX
Arduino slides
PPTX
Arduino Workshop Slides
PPTX
Microcontroller_basics_lesson1_2019 (1).pptx
PPT
Arduino_CSE ece ppt for working and principal of arduino.ppt
PPTX
Introduction to arduino Programming with
PDF
Intro arduino English
PPTX
Aurdino presentation
PDF
Introduction to Arduino Programming
PPTX
Getting started with arduino workshop
PPTX
Ch_2_8,9,10.pptx
PPT
13223971.ppt
PDF
IPEC Presentation - Partial discharge Pro .pdf
PPTX
Diffusion Models under Local Differential Privacy for Personalized Human Mobi...
 

More Related Content

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

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

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

Recently uploaded

PDF
IPEC Presentation - Partial discharge Pro .pdf
PPTX
Diffusion Models under Local Differential Privacy for Personalized Human Mobi...
 
PDF
Surveillance_Partner_Product_Training_20240120_KSA.pdf
PPTX
Coupled Hazard-Mobility Framework for Optimizing Emergency Vehicle Routing
PDF
Albert Pintoy - Specializing In Low-Latency
PPTX
Salesforce Bulk Connector V1 and V2 Deep Dive!
PPTX
Emerging Trends and Research Frontiers in Chemical Engineering for Green and ...
PDF
STOP CONSOLIDATION: Optimizing Transit Speed & Rider Experience
 
PPTX
UnrealGameplayAbilitySystemPresentation.pptx
PPTX
How to Select the Right CMMS Software for Your Organization — A Complete Buye...
PPTX
علي نفط.pptx هندسة النفط هندسة النفط والغاز
PPTX
The Importance of Maintenance Budgets — Maximize Reliability & Control Costs ...
PPTX
Plant Performance Strategies: Enhanced Reliability & Operational Efficiency w...
PPTX
Optimizing Plant Maintenance — Key Elements of a Successful Maintenance Plan ...
PDF
Narrows Planning Collective Transportation Capstone.pdf
 
PPTX
Track & Monitor Preventive Maintenance — Best Practices with MaintWiz CMMS
PPTX
Step-by-step guide to designing standard a microbiology laboratory in pharmac...
PDF
Advanced Intrusion Detection and Classification using Transfer Learning with ...
PPTX
Vertical turbine pump explains installed in power plants
PDF
Hybrid Anomaly Detection Mechanism for IOT Networks
IPEC Presentation - Partial discharge Pro .pdf
Diffusion Models under Local Differential Privacy for Personalized Human Mobi...
 
Surveillance_Partner_Product_Training_20240120_KSA.pdf
Coupled Hazard-Mobility Framework for Optimizing Emergency Vehicle Routing
Albert Pintoy - Specializing In Low-Latency
Salesforce Bulk Connector V1 and V2 Deep Dive!
Emerging Trends and Research Frontiers in Chemical Engineering for Green and ...
STOP CONSOLIDATION: Optimizing Transit Speed & Rider Experience
 
UnrealGameplayAbilitySystemPresentation.pptx
How to Select the Right CMMS Software for Your Organization — A Complete Buye...
علي نفط.pptx هندسة النفط هندسة النفط والغاز
The Importance of Maintenance Budgets — Maximize Reliability & Control Costs ...
Plant Performance Strategies: Enhanced Reliability & Operational Efficiency w...
Optimizing Plant Maintenance — Key Elements of a Successful Maintenance Plan ...
Narrows Planning Collective Transportation Capstone.pdf
 
Track & Monitor Preventive Maintenance — Best Practices with MaintWiz CMMS
Step-by-step guide to designing standard a microbiology laboratory in pharmac...
Advanced Intrusion Detection and Classification using Transfer Learning with ...
Vertical turbine pump explains installed in power plants
Hybrid Anomaly Detection Mechanism for IOT Networks

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