This video showing the ” | ” is moving when I pressed the button.
This video is showing “bbbbbbb” when I pressed the button in the around 65 seconds.
Electronic Learning Portfolio
This video showing the ” | ” is moving when I pressed the button.
This video is showing “bbbbbbb” when I pressed the button in the around 65 seconds.
The name of object: Super flash
Before a game starts:
Waiting for players to reset the instrument by pressing the reset button. The four blue and yellow LED lights are turned on.
During the game:
If the yellow LED light turns on when the player presses the button, then the player scores one point. After pressing the game button when then light flashes in the middle of the 5 lights, the buzzer also makes a sound, and the game will speed up and continue.
If the blue LED lights are turned on when the player presses the button, it indicates that the game is over.
code:
int Led1Pin = 2; //The pin of the first LED.
int Led2Pin = 3; //The pin of the second LED.
int Led3Pin = 4; //etc.
int Led4Pin = 5;
int Led5Pin = 6;
int ButtonPin = 8; //The pin of the button.
int BuzzerPin = 9;//The pin of the buzzer.
//The state of the button the last time we checked.
boolean old_val = LOW;
//Stores which LED is on.
int LightPosition = 0;
//How much time in between LED light changes.
int pause = 1000;
//What time it was when we last moved the light.
long lastMove = millis();
void setup()
{
pinMode(Led1Pin, OUTPUT);
pinMode(Led2Pin, OUTPUT);
pinMode(Led3Pin, OUTPUT);
pinMode(Led4Pin, OUTPUT);
pinMode(Led5Pin, OUTPUT);
pinMode(ButtonPin, INPUT);
Serial.begin(9600);
//Start a new game.
newGame();
}
void loop()
{
//Move the light.
if (millis() – lastMove >= pause)
{
lastMove = millis(); //Remember when we switched LED
LightPosition++; //increment the Light position.
if (LightPosition >= 6) LightPosition = 1;
move(LightPosition);//Update the light position.
}
//When the player presses the button…
if (digitalRead(ButtonPin) == HIGH && old_val == LOW)
{
//If the pressed it when the light was in the middle, speed up and continue.
if (LightPosition == 3)
{
digitalWrite(Led3Pin, LOW);
delay(50);
digitalWrite(Led3Pin, HIGH);
tone(BuzzerPin, 2470);
delay(1000);
tone(BuzzerPin, 3295);
delay(1000);
noTone(BuzzerPin);
//Speed up the game.
if (pause > 700)
{
pause -= 100;
} else if (pause > 500)
{
pause -= 50;
} else if (pause > 300)
{
pause -= 25;
} else if (pause > 10)
{
pause -= 10;
} else if (pause > 1)
{
pause -= 1;
}
Serial.print(“Score: “);
Serial.println(pause);
} else //If the pressed it at the wrong time, show their final score and start a new game.
{
//Game over
Serial.println(“GAME OVER”);
Serial.print(“Final Score “);
Serial.println(pause);
//Blink the Led that the player stopped on.
for (int x = 0; x <= 10; x++)
{
if (digitalRead(LightPosition + 1) == LOW)
{
digitalWrite(LightPosition + 1, HIGH);
}
else
{
digitalWrite(LightPosition + 1, LOW);
}
delay(200);
}
//Show a LED bar based on how well the player did.
digitalWrite(Led1Pin, HIGH);
delay(500);
if (pause < 800)
{
digitalWrite(Led2Pin, HIGH);
delay(500);
}
if (pause < 600)
{
digitalWrite(Led3Pin, HIGH);
delay(500);
}
if (pause < 250)
{
digitalWrite(Led4Pin, HIGH);
delay(500);
}
if (pause < 100)
{
digitalWrite(Led5Pin, HIGH);
delay(500);
}
delay(3000);
newGame();
}
}
old_val = digitalRead(ButtonPin);
}
//Updates the light’s position.
void move(int LightPosition)
{
//Turn off all LEDs
for (int x = Led1Pin; x <= Led5Pin; x++)
{
digitalWrite(x, LOW);
}
//Turn on the LED
digitalWrite(LightPosition + 1, HIGH);
}
void newGame()
{
LightPosition = 0;
pause = 1000;
Serial.println(“New Game: Score 1000”);
}
Arduino week1 assignment
The microcontroller on the board is programmed using the Arduino programming language (based on Wiring) and the Arduino development environment (based on Processing).
16×2 Character LCD module based on the HD44780 controller.
White characters on blue background with backlight.
Comes with headers, a diode and a variable resistor for your peace of mind.
The ProtoShield is prototype expansion board with 2 LEDs and 2 button, which can be used directly and more convenience. All the pins and power have been lead out. It is very suitable for building prototype circuit with Arduino.
This module has power-down stored function and can store 10 groups preset value.
This is a convenient package of seven Darlington transistors.
This is a ready-to-go cable and a machined drive shaft (so you can easily attach stuff). We drove it with an Adafruit motor shield for Arduino and it hummed along nicely at 50 RPM.
core motor
5V Relay Module 4-Channel.This is a 5V 4-Channel Relay interface board. Be able to control various appliances, and other equipment with large current. Indication LED’s for Relay output status.
Arduino Mini infrared wireless remote control kit consists of 38KHz infrared remote control and infrared receiver modules, Mini IR can transmit distances of up to 8 m
The kind of program that we need to monitor the joystick has to make a polling to two of the analog pins.
The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed).
The HRLV-MaxSonar-EZ sensor line is the fastest way to get precision range-finding into your computer.
electric scooter motor.
An active buzzer will generate a tone using an internal oscillator, so all that is needed is a DC voltage
Tilt sensors are switches that can detect basic motion/orientation.
These chips are DIP package so you can easily plug them into any breadboard or perfboard with 0.1″ spacing. The digital outputs are good for about 20mA, which makes them ideal for LEDs or driving power transistors.
Manufactured by Spectra Symbol, these are nice little ribbon controllers (also known as ‘soft potentiometers’) with an adhesive backing.
this a single LED.
this a single LED.
An active buzzer will generate a tone using an internal oscillator, so all that is needed is a DC voltage
Remote controller.
These nice switches are perfect for use with breadboard and perfboard projects. They have 0.1″ spacing and snap in nicely into a solderless breadboard.
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your NETduino.
Having different colors they greatly facilitate their recognition within a prototype (often a tangle of wires) so that they can be classified by function: red 5V, black GROUND, yellow PWM signal and so on.
For bread-boarding with unusual non-header-friendly surfaces, these cables will be your best friends! No longer will you have long strands of alligator clips that are grabbing little wires.
battery wire
Battery
handy resistor packs
LED light ball
Color LED light ball
This epoxy-coated precision 1% 10K thermistor is an inexpensive way to measure temperature in weather or liquids. T
put it between your DC power jack and circuitry to avoid a negative-voltage that would zap your delicate electronics
CdS cells are little light sensors. As the squiggly face is exposed to more light, the resistance goes down. When its light, the resistance is about 5-10KΩ, when dark it goes up to 200KΩ.
NPN transistors whenever we need to control medium-power electronics such as small motors, solenoids, or IR LEDs.
ii)A sample Fritzing schematic
iii)function or library is needed to make it work
Blink
Turns an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.
If you want to know what pin the on-board LED is connected to on your Arduino
model, check the Technical Specs of your board at:
https://www.arduino.cc/en/Main/Products
modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Blink
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}