Programming 101

Programming 101 © MIT

This unit will introduce students to programming in an Arduino environment by creating a simple device that uses an external sensor.

  • 5 views
  • 0 comments
  • 0 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

The goal of this unit:

Students will build on prior knowledge of basic circuitry - ground, power, completing a circuit - to build a simple device that utilizes data from an external sensor to control an output device.

CREATE - "Silent alarm" - Start with the ultrasonic sensor and some LEDs

IMPROVE - "Sound alarm" - Add sound using a Piezo speaker

FINESSE - "Musical alarm" - Make the note vary based on the distance detected by an ultrasonic sensor

INVENT - (Introduces photoresistor to replace the ultrasonic sensor) - How might you create an alarm that makes a rooster obsolete?

Code

Activity 1Arduino
BLINK an on board LED
/*
  Blink
  Turns on an LED on for one second, then off for one second, 
  repeatedly. This example code is in the public domain.
*/

// Identify the pin you will be using.
// Pin 13 has an LED connected on most Arduino boards.
int led = 13;

// The setup routine runs once when you press reset:

void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
  delay(1000); // This is written in milliseconds. 1000 = 1 second
  digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
  delay(1000); // wait for a second
}

Comments

Add projectSign up / Login