Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
What line(s) of code do you need to change to make the LED blink (like, at all)? pinMode(13, OUTPUT); digitalWrite(13, HIGH); digitalWrite(13, LOW); These lines need to have their pin changed to pin 11 for the teensy so they will look like this: pinMode(11, OUTPUT); digitalWrite(11, HIGH); digitalWrite(11, LOW); What line(s) of code do you need to change the rate of blinking? delay(1000); The value in the delay could be altered such that an increase in delay will decrease the rate of blinking and vice versa. What circuit element would you want to add to protect the board and LED? A resistor Which lines do you need to modify to correspond with your button and LED pins? const int ledPin = 13; The value in this line would change to 9 Modify the code or the circuit so that the LED lights only while the button is depressed. Include your code in your lab write-up. We would just change the argument in the if statement to if (buttonState == LOW) Code A Which lines of code do you need to modify to correspond with your button and LED pins? const int ledPin = 9; How would you change the rate of fading? I would change the values in the fade value or change the delay. (Extra) Since the human eye doesn't see increases in brightness linearly how could you change the code to make the light appear to fade linearly? In my opinion, if the light does not fade completely, then the fade seems to appear linear to the human eye. This means we can set the minimum light intensity the LED needs to be at in the code. Furthermore, as the human eye requires more time to respond to the fade, increasing the delay or decreasing the fade value will also help make the LED seem to fade more linearly to the human eye. Part B: What is the minimum resistor size that should be used with these LEDs? (Hint: think about your voltage supply and what the diode voltage drop means.) 60 ohms Is there computation in your device? Where is it? What do you think is happening inside the "computer?" There isn’t a microcontroller in the keyboard, however, there is a computation device which sends information to the computer that is then converted to which key has been pressed. On the switch board there is a microcontroller, probably to control the LEDs on the board and other computations that it is suppose to do. Are there sensors on your device? How do they work? How is the sensed information conveyed to other portions of the device? There are touch sensors that are made by 3 overlaying plastic sheets with the outer ones having metal wiring around them that hook up the keys. The middle plastic sheet separates the two sheets such that they are not constantly laying over each other. It also has holes at the positions of the buttons so that when the button is pressed, the connection between the two outer plastic sheets is closed and thus, is able to send the message that a specific key has been pressed. No sensors on the switch board, only switches, leds and a microcontroller. How is the device powered? Is there any transformation or regulation of the power? How is that done? What voltages are used throughout the system? The device takes in 5V and up to 275mA. This model is powered through a USB cable connected to the computer. Resistors in the keyboard regulate the power. On the switch board, two banana jumpers look like they power it. Is information stored in your device? Where? How? According to howStuffWorks, the microprocessor stores the last 16 keys pressed, however, the model in howStuffWorks shows a microprocessor in the keyboard whereas ours does not seem to have it. On the switch board, there is a microcontroller on it which means that it can probably store information. Frankenlight: This is my schematic I used for the frankenlight. It is like an extended version of the first part of lab. I hooked up the switches on the switch board to use as “buttons”. The digital pins where the wires went into the teensy are defined on the right and the output pins for the LED are also defined on the right. The code used can be found in the extract, code b at the end of the report. Code A: /* Button Turns on and off a light emitting diode(LED) connected to digital pin 9, when pressing a pushbutton attached to pin 2. The circuit: * LED attached from pin 9 to ground * pushbutton attached to pin 2 from +5V * 10K resistor attached to pin 2 from ground * Note: on most Arduinos there is already an LED on the board attached to pin 9. created 2005 by DojoDave <http://www.0j0.org> modified 28 Oct 2010 by Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/Tutorial/Button */ // constants won't change. They're used here to // set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 9; // the number of the LED pin // variables will change: int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop(){ // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); } // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == LOW) { // turn LED on: digitalWrite(ledPin, HIGH); } else { // turn LED off: digitalWrite(ledPin, LOW); } code B: const int button1Pin = 0; // the number of the pushbutton pin const int button2Pin = 1; // the number of the pushbutton pin const int button3Pin = 2; // the number of the pushbutton pin const int redLED = 4; // the number of the LED pin const int greenLED = 9 ; // the number of the LED pin const int yellowLED = 10 ; // the number of the LED pin const int button4Pin = 3; const int button5Pin = 7; const int button6Pin = 5; const int button7Pin = 6; // variables will change: int button1State = 0; // variable for reading the pushbutton status int button2State = 0; // variable for reading the pushbutton status int button3State = 0; // variable for reading the pushbutton status int button4State = 0; // variable for reading the pushbutton status int button5State = 0; // variable for reading the pushbutton status int button6State = 0; // variable for reading the pushbutton status int button7State = 0; // variable for reading the pushbutton status int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by int blinkDelay = 1000; void setup() { // initialize the LED pin as an output: pinMode(redLED, OUTPUT); // initialize the LED pin as an output: pinMode(greenLED, OUTPUT); // initialize the LED pin as an output: pinMode(yellowLED, OUTPUT); // initialize the pushbutton pin as an input: pinMode(button1Pin, INPUT); // initialize the pushbutton pin as an input: pinMode(button2Pin, INPUT); // initialize the pushbutton pin as an input: pinMode(button3Pin, INPUT); // initialize the pushbutton pin as an input: pinMode(button4Pin, INPUT); // initialize the pushbutton pin as an input: pinMode(button5Pin, INPUT); // initialize the pushbutton pin as an input: pinMode(button6Pin, INPUT); // initialize the pushbutton pin as an input: pinMode(button7Pin, INPUT); } void loop(){ // read the state of the pushbutton value: button1State = digitalRead(button1Pin); // read the state of the pushbutton value: button2State = digitalRead(button2Pin); // read the state of the pushbutton value: button3State = digitalRead(button3Pin); // read the state of the pushbutton value: button4State = digitalRead(button4Pin); // read the state of the pushbutton value: button5State = digitalRead(button5Pin); // read the state of the pushbutton value: button6State = digitalRead(button6Pin); // read the state of the pushbutton value: button7State = digitalRead(button7Pin); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (button1State == HIGH) { // turn LED on: digitalWrite(redLED, HIGH); } else { // turn LED off: digitalWrite(redLED, LOW); } if (button2State == HIGH) { // turn LED on: digitalWrite(greenLED, HIGH); } else { // turn LED off: digitalWrite(greenLED, LOW); } if (button3State == HIGH) { // turn LED on: digitalWrite(yellowLED, HIGH); } else { // turn LED off: digitalWrite(yellowLED, LOW); } if (button4State == HIGH){ // activates blinking light digitalWrite(redLED, HIGH); // set the LED on delay(blinkDelay); // wait for a second digitalWrite(redLED, LOW); // set the LED off delay(blinkDelay); // wait for a second } } } } } if (button5State == HIGH){ // activates the fading lights effect analogWrite(redLED, brightness); brightness = brightness + fadeAmount; if(brightness == 0 || brightness == 255){ fadeAmount = -fadeAmount; } delay(80); if (button6State == HIGH){ //decreases the rate at which blink/fade occurs if( blinkDelay < 10000 ){ blinkDelay += 200; } if( fadeAmount > 5 ){ fadeAmount -= 5; }; if (button7State == HIGH){ //increases the rate at which blink/fade occurs if( blinkDelay > 200 ){ blinkDelay -= 200; } if (fadeAmount < 25 ){ fadeAmount += 5; }