Presentation is loading. Please wait.

Presentation is loading. Please wait.

Franz Duran INTRODUCTION TO A RDUINO PROGRAMMING & INTERFACING Engr. Franz Duran, MEP-ECE RapidSignal Electronics.

Similar presentations


Presentation on theme: "Franz Duran INTRODUCTION TO A RDUINO PROGRAMMING & INTERFACING Engr. Franz Duran, MEP-ECE RapidSignal Electronics."— Presentation transcript:

1 Franz Duran INTRODUCTION TO A RDUINO PROGRAMMING & INTERFACING Engr. Franz Duran, MEP-ECE RapidSignal Electronics

2 Franz Duran OVERVIEW Microcontrollers & Robotics

3 Franz Duran OVERVIEW  DAY 1 (Morning) o Introduction to Microcontroller Technology o Introduction to Arduino microcontroller board o Introduction to RapiDuino Microcontroller Learning Module o Basic Arduino Programming and Interfacing  Interfacing with LEDs, switches, & LCD Microcontrollers & Robotics

4 Franz Duran OVERVIEW  DAY 1 (Afternoon) o Interfacing with 4x4 keypad o Interfacing with Analog Sensors o Interfacing with Serial Communication Microcontrollers & Robotics

5 Franz Duran OVERVIEW  DAY 2 (Morning) o Introduction to P-BOT mobile robot trainer o Maze mobot programming o Line follower mobot programming Microcontrollers & Robotics

6 Franz Duran OVERVIEW  DAY 2 (Afternoon) o Line follower mobot race o Android-controlled mobot o DIY line follower mobot Microcontrollers & Robotics

7 Franz Duran MICROCONTROLLER BASICS Microcontrollers & Robotics

8 Franz Duran What is a microcontroller?  MCU  A single-chip computer  Invented in the 1970’s  Used as “embedded” controller Microcontrollers & Robotics

9 Franz Duran Where are MCUs used?  used as dedicated controllers in: o Home and office appliances o Consumer & Personal electronics o Medical equipment o Industrial equipment o Automotive electronics o Naval/Avionics/Aerospace Microcontrollers & Robotics

10 Franz Duran Why use a microcontroller?  Low-cost  Flexible  Small outline  Low-power Microcontrollers & Robotics

11 Franz Duran Why use a microcontroller?  Low-cost o Typical price range: P50 to P1000  Flexible  Small outline  Low-power Microcontrollers & Robotics

12 Franz Duran Why use a microcontroller?  Cheap  Flexible o Re-programmable o High-integration devices  Small outline  Low-power Microcontrollers & Robotics

13 Franz Duran Why use a microcontroller?  Cheap  Flexible  Small outline o small physical size = low PCB footprint o tiny packages: DIP, SOP  Low-power Microcontrollers & Robotics

14 Franz Duran Why use a microcontroller?  Cheap  Flexible  Small outline  Low-power o Battery-operated application o Use SLEEP/low-power operation Microcontrollers & Robotics

15 Franz Duran ARDUINO MICROCONTROLLER Microcontrollers & Robotics

16 Franz Duran What is an Arduino?  A microcontroller board + programming IDE Microcontrollers & Robotics

17 Franz Duran What is an Arduino?  A complete MCU board o ATMEGA microcontroller o USB circuit o Power supply circuit o Reset button o Female header connectors Microcontrollers & Robotics

18 Franz Duran What is an Arduino?  Easy-to-use Arduino Development environment o Program is called Sketch Microcontrollers & Robotics

19 Franz Duran Arduino ECOSYSTEM  Arduino Board o Simple, open-hardware design  Arduino Programming IDE o C/C++-based, open-source o Built-in functions  Arduino Community o Design Arduino-compatible circuits (Shields) o Software and hardware collaboration Microcontrollers & Robotics

20 Franz Duran RAPIDUINO SWORD3 Microcontrollers & Robotics

21 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics ARDUINO BOARD

22 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics Arduino Uno gizDuino

23 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics 2x16 Character LCD

24 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics Button Switches

25 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics 4x4 Keypad

26 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics 4x4 Keypad

27 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics 7-segment displays

28 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics Light- emitting diodes

29 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics Real-time clock w/ back-up battery

30 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics Serial EEPROM

31 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics buzzer

32 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics Serial Communication Circuit

33 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics Bluetooth Transceiver Module

34 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics Analog voltage sources

35 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics Temperature sensor

36 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics light- dependent resistor

37 Franz Duran RapiDuino Sword3 Microcontrollers & Robotics Power Supply Circuit

38 Franz Duran BASIC ARDUINO PROGRAMMING & INTERFACING Microcontrollers & Robotics

39 Franz Duran LED Interfacing  Build an LED circuit  Interface the LED circuit to the Arduino  Create an Arduino program that will turn on the LED Microcontrollers & Robotics

40 Franz Duran What is an LED?  Light-emitting diode o An electronic device that emit visible light when activated. o Typically used as electrical status indicators Microcontrollers & Robotics

41 Franz Duran LED Interfacing Microcontrollers & Robotics Circuit schematic

42 Franz Duran LED Circuit Microcontrollers & Robotics Circuit on breadboard

43 Franz Duran LED Circuit on Rapiduino  Connect LED1 to Arduino Pin 7 Microcontrollers & Robotics

44 Franz Duran Arduino Environment  Open the Arduino programming environment Microcontrollers & Robotics

45 Franz Duran Writing the Sketch void setup() { } void loop() { } Microcontrollers & Robotics Example #1

46 Franz Duran Writing the Sketch void setup() { pinMode(7, OUTPUT); //Pin 7 is output pin. digitalWrite(7, HIGH); //LED is on. } void loop() { } Microcontrollers & Robotics Example #1

47 Franz Duran Writing the Sketch void setup() { pinMode(7, OUTPUT); //Pin 7 is output pin. digitalWrite(7, HIGH); //LED is on. pinMode(5, OUTPUT); digitalWrite(5, HIGH); } void loop() { } Microcontrollers & Robotics Example #1

48 Franz Duran Writing the Sketch  Click the Verify button Microcontrollers & Robotics Verify button

49 Franz Duran Steps for Uploading the Program 1.Connect the USB cable Microcontrollers & Robotics Note: Make sure USB-to-serial driver is installed first

50 Franz Duran Steps for Uploading the Program 2.Power up the Rapiduino board Microcontrollers & Robotics

51 Franz Duran Steps for Uploading the Program 3.Select the COM port number of the Serial Port Microcontrollers & Robotics

52 Franz Duran Steps for Uploading the Program 4.Select the Arduino Duemilanove w/ ATmega328 board Microcontrollers & Robotics

53 Franz Duran Steps for Uploading the Program 5.Press down the Reset button Microcontrollers & Robotics

54 Franz Duran Steps for Uploading the Program 6.While Reset button is pressed, click the Upload button 7.Release the Reset button Microcontrollers & Robotics Upload button

55 Franz Duran Steps for Uploading the Program Wait… … until uploading is done. Microcontrollers & Robotics

56 Franz Duran Steps for experimenting with the Rapiduino 1.Assemble the Arduino application hardware o Use ordinary solid wires 2.Write the sketch program 3.Upload program to Arduino Microcontrollers & Robotics

57 Franz Duran Arduino Sketch int LED1Pin = 7; //PIN7 is 'renamed' as LED1 void setup() { pinMode(LED1Pin, OUTPUT); digitalWrite(LED1Pin, HIGH); } void loop() { //nothing... } Microcontrollers & Robotics Example #1

58 Franz Duran Arduino Program  Called as Sketch o A simplified combination of C/C++ programming language  Consist of: osetup() function oloop() function Microcontrollers & Robotics

59 Franz Duran Arduino Program  The setup() function o The setup() function is called when a sketch program begins executing. o It is used to initialize variables, configure pin modes, begin using libraries, etc. o The setup() function will only run once, after each powerup or reset of the Arduino board. Microcontrollers & Robotics

60 Franz Duran Arduino Program  The loop() function o The loop() function repeatedly execute all codes appearing within its body. o Use it to actively control the Arduino board, i.e. read input, process information, send output Microcontrollers & Robotics

61 Franz Duran Arduino Program void setup() { //code1 //code2 } void loop() { //code3 //code4 //code5 } Microcontrollers & Robotics code1 code5 start code2 code4 code3

62 Franz Duran LED Interfacing  LED Blinker program Microcontrollers & Robotics Example #2 Configure Output pin start LED is off Time delay LED is on Time delay LED is off

63 Franz Duran Arduino Sketch: LED Blinker int LED1Pin = 7; void setup() { pinMode(LED1Pin, OUTPUT);//Pin 7 is output pin digitalWrite(LED1Pin, LOW);//LED is initially low } void loop() { digitalWrite(LED1Pin, HIGH);//Turn on LED. delay(500);//Time delay for 0.5 second. digitalWrite(LED1Pin, LOW);//Turn off LED. delay(250);//Time delay for 0.25 second. } Microcontrollers & Robotics Example #2

64 Franz Duran Button Switch Interfacing  Button switch: o a.k.a pushbutton or button o Used as simple input devices  Common example: o Tact switches Microcontrollers & Robotics

65 Franz Duran Button Switch Interfacing Microcontrollers & Robotics

66 Franz Duran Button Switch Interfacing Microcontrollers & Robotics Circuit on breadboard

67 Franz Duran Button Switch Interfacing  Program Description: o If button is pressed, turn on LED. o Else, if button is not pressed, turn off LED.  Operation: o Button is connected to Pin 5. o Pin 5 is configured as input pin o If button is pressed, Pin 5 reads Logic 0; else, if not pressed reads as Logic 1 Microcontrollers & Robotics

68 Franz Duran Button Switch Interfacing  Assemble circuit on Rapiduino: o LED1  Pin 7 o BUTTON1  Pin 5 Microcontrollers & Robotics

69 Franz Duran Arduino Sketch int LED = 7; int BUTTON = 5; void setup() { pinMode(BUTTON, INPUT); pinMode(LED, OUTPUT); digitalWrite(LED, LOW); } void loop() { int ButtonStat; ButtonStat = digitalRead(BUTTON); if(ButtonStat == LOW) { digitalWrite(LED, HIGH); } else { digitalWrite(LED, LOW); } } Microcontrollers & Robotics Example #3

70 Franz Duran 2x16 Character LCD Interfacing  Output device for displaying characters  2 rows, 16 characters Microcontrollers & Robotics

71 Franz Duran 2x16 Character LCD Interfacing Microcontrollers & Robotics POWER Pins CONTROL Pins DATA Pins BACKLIGHT LED pins 1 16

72 Franz Duran 2x16 Character LCD Interfacing Microcontrollers & Robotics Circuit on breadboard

73 Franz Duran 2x16 Character LCD Interfacing Microcontrollers & Robotics

74 Franz Duran 2x16 Character LCD Interfacing  Assemble circuit on Rapiduino: o LCD_RS  Pin 12 o LCD_EN  Pin 11 o LCD_D4  Pin 14 o LCD_D5  Pin 15 o LCD_D6  Pin 16 o LCD_D7  Pin 17 o LCD_RW  Ground (NOTE: Short J3 jumper) Microcontrollers & Robotics

75 Franz Duran 2x16 Character LCD Interfacing #include LiquidCrystal lcd(12, 11, 14, 15, 16, 17);//lcd pins void setup() { lcd.begin(16, 2); //set up the LCD's number of columns and rows: lcd.print("RapiDuino SWORD3"); //Print a text on first line lcd.setCursor(1, 1); //Move cursor to 2nd line lcd.print("with Bluetooth!");//Print a text on second line } void loop() { //Do nothing... } Microcontrollers & Robotics Example #4

76 Franz Duran END


Download ppt "Franz Duran INTRODUCTION TO A RDUINO PROGRAMMING & INTERFACING Engr. Franz Duran, MEP-ECE RapidSignal Electronics."

Similar presentations


Ads by Google