1 / 43

Arduino 101 Class

Arduino 101 Class. For those new to programming and the Arduino. Version 3.2. About Me. Objectives. Introductions. History and Purpose. Basic Arduino: The Arduino Uno. Other Arduinos And Compatibles. Circuit Playground Express. Adafruit Flora. Adafruit Gemma (also LilyPad).

oliverio
Download Presentation

Arduino 101 Class

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. Arduino 101 Class For those new to programming and the Arduino Version 3.2

  2. About Me

  3. Objectives

  4. Introductions

  5. History and Purpose

  6. Basic Arduino: The Arduino Uno

  7. Other Arduinos And Compatibles Circuit Playground Express Adafruit Flora Adafruit Gemma (also LilyPad) Arduino Tiny (also Atom X1) Arduino Nano Adafruit Huzzah Feather Arduino Pro Mini Sparkfun Uno clone

  8. What Can Arduinos Do? They have full processors to run any kind of general processing you want, though they are relatively slow, single threaded, and not good at floating point math and don’t have lots of memory They run “near real time”, which means they are good for exact timing and predictable execution speed They draw very little power compared to full computers They are great at controlling many kinds of devices They are great at getting input from many kinds of devices They have serial ports and USB to communicate with other devices, including your PC. They have other communication interfaces like I2C and SPI, and even more can be added with small add-on boards like CAN and DMX.

  9. Programming Arduinos

  10. Basic Rules Of Using Arduino C

  11. Components Of A Program

  12. Comments

  13. Variables

  14. Constants

  15. Operations

  16. Conditionals if( col > MAX_COL) { col = MAX_COL); } if( col == MIN_COL) { // == is comparison col = 17; // = is assignment } if( col >= MAX_COL) { // Increment col if within range col = MAX_COL; } else { col++; } “if()” is the main conditional, but there are others new_col = col > MAX_COL ? MAX_COL : col+1; // ternary operator Switch statements can be used to branch based on different possible values

  17. Loops // Loop the integer x through all the digits // for(setup ; conditional ; iteration) { } for(int x=0; x < 10 ; x++) { Serial.println(x); } // while(conditional) { } int x = 0; while(x < 10) { Serial.println(x); x++ }

  18. Unique To Arduino

  19. Your Arduino 101 Kit

  20. OK! Let’s look at some code!

  21. Hello World, Arduino Style

  22. The Blink Example, Annotated /* < ------- Anything between /* and */ are comments, and not executed. Blink Turns an LED on for one second, then off for one second, repeatedly. … */ // the setup function runs once when you press reset or power the board void setup() { < ------- setup() is a function called at the startup // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT); } // the loop function runs over and over again forever void loop() { < ------- Arduino programs don’t have an end. They loop forever. digitalWrite(LED_BUILTIN, HIGH); // Turn the pin on, turning the LED on delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // Turn the pin off, turning the LED off delay(1000); // wait for a second }

  23. Let’s Make Blink Interactive

  24. Wiring Up The Button

  25. Wiring Up The Button

  26. Change The Software And Run It

  27. What’s Changed in the code?

  28. Let’s Turn It Into A Light Sensor

  29. Wiring Up The Photosensor

  30. Wiring Up The Photosensor

  31. lightblink.ino const int sensorPin = A0; // Select the input pin for the light sensor const int ledPin = 13; // Select the pin for the LED void setup() { Serial.begin(9600); // Set up the serial port to talk to the PC pinMode(ledPin, OUTPUT); // Declare the ledPin as an OUTPUT: Serial.println("Starting"); } void loop() { // Read the value from the sensor, 0-1024, but generally over 600 int sensorValue = analogRead(sensorPin); // map() takes a value in an expected input range and scales it to // a different output range. Here I am also reversing the low and // high so the higher the resistance, the lower the delay, the // faster it blinks int delayValue = map(sensorValue, 600, 1024, 1000, 200); Serial.print("Sensor: "); Serial.print(sensorValue); Serial.print(" Delay: "); Serial.println(delayValue); digitalWrite(ledPin, HIGH); // Turn the ledPin on delay(delayValue); // Pause for <delayValue> milliseconds: digitalWrite(ledPin, LOW); // Turn the ledPin off: delay(delayValue); // Pause for for <delayValue> milliseconds: }

  32. Change The Software And Run It

  33. Keep Calm And Code On

  34. Example Projects

  35. What Would Your First Project Be?

  36. Arrays #define COINS_MAX 4 int coins[COINS_MAX]; coins[0]=1; coins[1]=5; coins[2]=10; coins[3]=25; for(int x=0; x < COINS_MAX; x++) { // x should go from 0 to 1 to 2 to 3 but not 4 Serial.println( coins[x]); }

  37. Strings

  38. What can you connect to an Arduino as input or output?

  39. Reference Arduino website: https://www.arduino.cc/ Espressif ESP32https://en.wikipedia.org/wiki/ESP32 Esspressif ESP8266https://en.wikipedia.org/wiki/ESP8266 Adafruithttps://www.adafruit.com/ Sparkfunhttps://www.sparkfun.com You Do It Electronicshttp://www.youdoitelectronics.com/ Microcenterhttps://www.microcenter.com/

  40. What have I done with Arduinos

  41. What should I change?

  42. Thank you all! I look forward to your questions and feedback david@thekramers.net You can download my presentations at http://www.thekramers.net/r/arduino/

More Related