1 / 14

Practical Electronics & Programming

Practical Electronics & Programming . with Arduino. Session 3: Strings Cont. What is an array?. Arrays are data stored back-to-back:. byte nums[] = { 1, 2 }. 2. 1. 0000 0001 0000 0010. Arrays. You can access individual parts based on an 'index' that starts at 0:. 2. 1. nums =.

doane
Télécharger la présentation

Practical Electronics & Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Practical Electronics & Programming with Arduino Session 3: Strings Cont.

  2. What is an array? Arrays are data stored back-to-back: byte nums[] = { 1, 2 } 2 1 0000 0001 0000 0010

  3. Arrays You can access individual parts based on an 'index' that starts at 0: 2 1 nums = 0000 0001 0000 0010 1 2 nums[0] = nums[1] = 0000 0001 0000 0010 index 0 index 1

  4. What is a String? Strings are arrays of characters (8 bits) terminated by a special '\0' character "Hello."= l e . \0 l H o

  5. Number String Parsing Takes input of 5670 Converts it to an int Prints it Add 5 to the converted input Print it

  6. String Parsing Until the string end is reached Output: H e l l o . Get the char at the index Print it out Advance one Character

  7. Character Display http://arduino.cc/en/Tutorial/LiquidCrystal

  8. Example Wiring

  9. Example Code #include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); voidsetup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); } voidloop() { // 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); }

  10. Character Display

  11. Ultrasonic Distance Emitter Receiver

  12. Ultrasonic Distance 1 - Ultrasonic Pulse sent 2 - Sounds bounces off target 3 - Bounced sound returns, time taken tells distance

  13. Interfacing

  14. Example Code

More Related