Wednesday, November 5, 2014

Proyecto final


​​


El proyecto busca la creación de una caja de respuestas, de preguntas de si o no. 
La respuesta se vera reflejada en la pantalla LCD y en un led de color. 


int r = 10;
int g = 9;
int b = 8;
int boton = 7;

int val = 0;
int rn = 0;

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


void setup(){
  pinMode(r, OUTPUT); 
  pinMode(g, OUTPUT); 
  pinMode(b, OUTPUT);
  pinMode(boton, INPUT);
    randomSeed(rn);
    
      lcd.begin(16, 2);
}

void loop(){

  val = digitalRead(boton);


  if(val==HIGH){
    delay(10);  
    rn = random(0,3);

    if(rn==0){
      digitalWrite(r, HIGH);
        lcd.setCursor(0, 0);
      lcd.print("Hell no");
      delay(3000);   //time red LED is on
      digitalWrite(r, LOW);  
       //lcd.setCursor(0, 1);
      //lcd.print("try again?");
      //lcd.clear(0,12);
    }

    if(rn==1){
      digitalWrite(g, HIGH);
        lcd.setCursor(0, 0);
      lcd.print("Fuck yeah");
      delay(3000);   //time green LED is on
      digitalWrite(g, LOW);  
       //lcd.setCursor(0, 1);
      //lcd.print("try again?");
      //lcd.clear();
    }
    
    if(rn==2){
      digitalWrite(b,HIGH);
        lcd.setCursor(0, 0);
      lcd.print("No idea");
      delay(3000);
      digitalWrite(b,LOW);
       //lcd.setCursor(0, 1);
      //lcd.print("try again?");
      //lcd.clear();
    
    }
  }
  delay(5);
}

--
Nicole Rodríguez Sánchez
Cel: 311 211 3161

No comments:

Post a Comment