Archive for the 'Uncategorized' Category

Semáforo de autos y peatonal con botón usando Arduino

Para empezar a probar circuitos básicos, decidí seguir algunos de los tutoriales, en particular me pareció interesante el de Semáforo de autos y peatonal interactivo que está en el libro Arduino Starter Kit Manual de Mike McRoberts , este es el diagrama:

Y este el circuito que armé basado en el diagrama, en la foto funcionando con una batería de 9v, teniendo cuidado que el positivo esté en el centro del conector a la placa.

Arduino con circuito de Semáforo

Arduino con circuito de Semáforo

Como el semáforo estaba programado para la lógica de Reino Unido, cambié un poco la lógica del sketch (programa) y los tiempos para Argentina:

// Project 4 - Interactive Traffic Lights
int carRed = 12; // assign the car lights
int carYellow = 11;
int carGreen = 10;
int pedRed = 9; // assign the pedestrian lights
int pedGreen = 8;
int button = 2; // button pin
int crossTime = 7000; // time allowed to cross
unsigned long changeTime; // time since button pressed
void setup() {
pinMode(carRed, OUTPUT);
pinMode(carYellow, OUTPUT);
pinMode(carGreen, OUTPUT);
pinMode(pedRed, OUTPUT);
pinMode(pedGreen, OUTPUT);
pinMode(button, INPUT); // button on pin 2
// turn on the green light
digitalWrite(carGreen, HIGH);
digitalWrite(pedRed, HIGH);
}
void loop() {
int state = digitalRead(button);
/* check if button is pressed and it is
over 5 seconds since last button press */
if (state == HIGH && (millis() - changeTime) > 5000) {
// Call the function to change the lights
changeLights();
}
}
void changeLights() {
digitalWrite(carGreen, LOW); // green off
digitalWrite(carYellow, HIGH); // yellow on
delay(2000); // wait 2 seconds
digitalWrite(carYellow, LOW); // yellow off
digitalWrite(carRed, HIGH); // red on
delay(1500); // wait 1 second till its safe
digitalWrite(pedRed, LOW); // ped red off
digitalWrite(pedGreen, HIGH); // ped green on
delay(crossTime); // wait for preset time period
// flash the ped green
digitalWrite(pedGreen, LOW); // ped red off
for (int x=0; x<10; x++) {
digitalWrite(pedRed, HIGH);
delay(500);
digitalWrite(pedRed, LOW);
delay(500);
}
// turn ped red on
digitalWrite(pedRed, HIGH);
delay(500);
digitalWrite(carYellow, HIGH); // yellow on
digitalWrite(carRed, LOW); // red off
delay(1000);
digitalWrite(carGreen, HIGH);
digitalWrite(carYellow, LOW); // yellow off
// record the time since last change of lights
changeTime = millis();
// then return to the main program loop
}

El resultado final puede verse en el siguiente video para móviles

o embebido:

Categorías

RSS Entradas GReader Compartidas

  • Programming Interactivity - O'Reilly Media Thursday, September 8, 2011
    Processing, a Java-based programming language and environment for building projects on the desktop, Web, or mobile phones; Arduino, a system that integrates a microcomputer prototyping board, IDE, and programming language for ... […]
    O'Reilly Media
  • Google+ suma juegos Monday, August 15, 2011
    Shared by Guille Ya me envicié con Angry Birds en G+ también! La red social del gigante de internet agregó juegos a su propuesta, entre ellos Angry Birds, que causó sensación a nivel global, en un nuevo intento por disputar a facebook la primacía en la vida online de los usuarios […]
    (author unknown)
  • Book Review: Getting Started With Audacity 1.3 Monday, August 15, 2011
    MassDosage writes "Getting Started with Audacity 1.3 by Bethany Hiitola covers the basics of using the Audacity software package for recording and editing audio. This book is written in a tutorial style and stays true to its title by covering Audacity from a newcomer's perspective with lots of diagrams and detailed explanations of how to install an […]
    samzenpus
  • Arduino Code Syntax Highlighting Plugin for your WordPress Blog Sunday, August 14, 2011
    Download and install this Arduino code highlighting and markup WordPress plugin. […]
    admin
  • How to Hack Your Wii for Homebrew in Five Minutes [Video] Friday, August 12, 2011
    Hacking your Wii hasn't been difficult, but it has required a somewhat detailed process. Now we have LetterBomb, which is an incredibly simple way to hack your Wii. It only takes about five minutes to accomplish. Here's how to do it. First things first, you're going to need the following: A Nintendo Wii, obviously, but make sure it's runn […]
    Adam Dachis
  • Wii homebrew hack – no game discs required - Hack a Day Friday, August 12, 2011
    Jailbreaking hacks have come and gone for the Wii, ever changing as Nintendo tweaks their software to prevent homebrew from running. Piracy concerns aside, there is a legitimate Wii homebrew scene, and a new, ... […]
    Mike Nathan
  • Gentoo Linux libera el LiveDVD 11.2 Monday, August 8, 2011
    Gentoo Linux liberó el LiveDVD 11.2 Edición “The future is now” Gentoo Linux está orgulloso en anunciar la disponibilid de un nuevo LiveDVD para celebrar la continua colaboración entre usuarios y desarrolladores Gentoo. El LiveDVD contiene una impresionante lista de paquetes, alguno de los cuales están listados abajo. Paquetes del sistema: Linux kernel 3.0 ( […]
    Guille
  • Gentoo Linux releases 11.2 LiveDVD Monday, August 8, 2011
    "The future is now" edition Gentoo Linux is proud to announce the availability of a new LiveDVD to celebrate the continued collaboration between Gentoo users and developers. The LiveDVD features a superb list of packages, some of which are listed below. System packages include: Linux kernel 3.0 (with Gentoo patches), Accessibility Support with Spea […]
    David Abbott
  • Capacitor Replacement Tutorial #twt Capacitor Replacement Tutorial http://w Wednesday, August 3, 2011
    Capacitor Replacement Tutorial #twt Capacitor Replacement Tutorial http://www.youtube.com/v/YCSNWi3UHf4&hl=en&fs=1&autoplay=1 […]
    (author unknown)
  • Start Google Plus Combines Google+ with Facebook and Twitter [Downloads] Tuesday, August 2, 2011
    Start Google Plus is a great extension for Chrome and Firefox that lets you update Twitter and Facebook from within Google+, also adding feeds from both social networks onto your main page. We mentioned it in our Facebook to Google+ migration guide, but felt it deserved to be highlighted on its own because it's so useful. To get started, you just downlo […]
    Adam Dachis

Creative Commons License
blog.nivel7.com.ar is licensed under a Creative Commons Attribution 3.0 Unported License.