MAKECourse
  • Home
  • About
  • Course Materials
    • Software
    • Course Kits
    • TA hours
  • Videos
    • Intro to Programming Videos
    • Advanced Topics >
      • DAC and ADC Tutorial
      • SD Card Data Logging
      • DC Motor Control
  • Schedule
    • Syllabus
  • Student Projects
    • Awesome Prizes
    • Fall 2020 Projects
    • Fall 2016 Awesome Prize Winners
    • Fall 2016 Projects
    • Spring 2016 Awesome Prize Winners
    • Spring 2016 Projects
    • Fall 2015 Awesome Prize Winners
    • Fall 2015 Projects
    • Spring 2015 Awesome Prize Winners
    • Spring 2015 Projects
    • Fall 2014 Projects
    • Spring 2014 Projects

Week 6. Segment 1: Object Oriented Programming in Arduino Sketches

In this segment we will learn to use Object Oriented (OO) Programming. OO is a great way to generate well-structured Arduino sketches with a minimum of programming bugs. Furthermore, objects are a nice way to share code for the operation of standard hardware devices (LCD, ICs etc...) connected to the Arduino.

Goals:

  • Understand the concept of Object Oriented Programming
  • Use objects to control digital pins

In-Class Project (and probably homework):
  • Translate the push button binary counter sketch into an OO sketch using a class.
  • Call the class "BinaryCounter"
  • The 'methods' of this class should be:
  • void BinaryCounter::countUP(); this is supposed to increase the counter by +1.
  • void BinaryCounter::countDOWN() (this is supposed to decrease the counter by -1.
  • void BinaryCounter::turnDisplayOff() (this is supposed to turn all the LEDs off, that the display appears dark).
  • void BinaryCounter::setValue(byte number) (this is supposed to set the counter to a specific state
  • byte BinaryCounter::getValue() (this is supposed to return the current value of the counter)

Materials for this segment:
  • Watch the video on the right.
  • 'Instructable' on how to control buttons through objects.
  • Commented Arduino sketch used in the video (use link below the video)

Arduino Sketch used in tutorial
File Size: 1 kb
File Type: zip
Download File

Improved sketch that uses an array to access the objects:
led_flasher_objects_array.zip
File Size: 1 kb
File Type: zip
Download File

[Home] [Course Materials] [Syllabus] [Student Projects] [Contact]
Powered by Create your own unique website with customizable templates.