Site Map - skip to main content - dyslexic font - mobile - text - print

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.


hpr1908 :: Arduino Pumpkin

droops talks about how his class built a pumpkin that comes alive for halloween.

<< First, < Previous, Latest >>

Hosted by droops on 2015-11-25 is flagged as Clean and is released under a CC-BY-NC-SA license.
Listen in ogg, spx, or mp3 format. | Comments (1)

Part of the series: Arduino and related devices

In this series various contributors talk about how to use and program Arduino single-board microcontrollers and related devices.
See the Wikipedia article https://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems for details of the range of devices.

Code for Pumpkin

int ledPin1 = 5;
int ledPin2 = 6;
int motorPin = 8;
int lightPin = 3;
int lightVal;
int potPin = 0;
int potVal;

void setup(){
  Serial.begin(9600);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(motorPin, OUTPUT);
  pinMode(potPin, INPUT);
  pinMode(lightPin, INPUT);
  digitalWrite(ledPin1, LOW);
  digitalWrite(ledPin2, LOW);
  digitalWrite(motorPin, LOW);
}

void loop(){
  potVal = analogRead(potPin);
  lightVal = analogRead(lightPin);
  Serial.println(lightVal);
  if (lightVal < potVal){
    animate();
  }
}

void animate(){
  digitalWrite(ledPin1, HIGH);
  digitalWrite(ledPin2, HIGH);
  digitalWrite(motorPin, HIGH);
  delay(100);
  digitalWrite(ledPin1, LOW);
  digitalWrite(ledPin2, LOW);
  digitalWrite(motorPin, LOW);
}

Comments

Subscribe to the comments RSS feed.

Comment #1 posted on 2015-11-28T22:01:21Z by Dave Morriss

Loved this!

A very cool project.

I'm in envy of your students.

Leave Comment

Powered by Comment Script