Arduino Uno
-
- Posts: 118
- Joined: Sun Apr 03, 2016 6:42 am
- Location: Michigan
Re: Arduino Uno
You would have better luck trying to do that with a Raspberry Pi rather than the Arduino Uno However they can both run full versions of Windows, Linux, and Mac OSX
-
- Posts: 118
- Joined: Sun Apr 03, 2016 6:42 am
- Location: Michigan
Re: Arduino Uno
I am sure that if you look into it, someone has done something that you are looking at doing
Re: Arduino Uno
Yeah, I didn't sit through the whole vid myself, seeing it was over 6 hrs. long, I just went by what the title relayed.
-
- Posts: 118
- Joined: Sun Apr 03, 2016 6:42 am
- Location: Michigan
Re: Arduino Uno
This is my first somewhat complex program to make an LED turn on and off, and make it fade in and out when the button is pressed. I know it is extremely simple, but as I said before I would keep posting about what I am learning.
Code: Select all
// Example 05: Turn on LED when the button is pressed
// and keep it on after it is released
// including simple de-bouncing.
// If the button is held. brightness changes
const int LED = 9; // the pin for the LED
const int BUTTON = 7; // the input pin of the pushbutton
int val = 0; // stores the state of the input pin
int old_val = 0; // stores the previous value of "val"
int state = 0; // 0 = LED off while 1 = LED on
int brightness = 120; // Stores the brightness value
unsigned long startTime = 0; // when did we begin pressing?
void setup() {
pinMode(LED, OUTPUT); // tell Arduino LED is an output
pinMode(BUTTON, INPUT); // and BUTTON is an input
}
void loop() {
val = digitalRead(BUTTON); // read input value and store it
//check if there was a transition
if ((val == HIGH) && (old_val == LOW)) {
state = 1 - state; //change the state from off to on
// or vice-versa
startTime = millis(); // millis() is the Arduino clock
// it returns how many milliseconds
// have passed since the board has
// been reset.
// (this line remembers when the button
// was last pressed)
delay(10);
}
// check whether the button is being held down
if ((val == HIGH) && (old_val == HIGH)) {
// If the button is held for more than 500ms
if (state == 1 && (millis() - startTime) > 500) {
brightness++; //increment brightness by 1
delay(10); // delay to avoid brightness going
// up too fast
if (brightness > 255) { // 255 is the max brightness
brightness = 0; //If we go over 255
// let's go back to 0
}
}
}
old_val = val; // val is now old, let's store it
if (state == 1) {
analogWrite(LED, brightness); // turn LED ON at the
// current brightness level
} else {
analogWrite(LED, 0); // turn LED OFF
}
}
- Attachments
-
- Just a small circuit with the LED
- IMG_0380.JPG (52.75 KiB) Viewed 912 times
Re: Arduino Uno
i looked at this tech once for building an arcade cabinet. using one of these to wire all the buttons if i remember right.
-
- Posts: 118
- Joined: Sun Apr 03, 2016 6:42 am
- Location: Michigan
Re: Arduino Uno
very possible. I will have to ask my dad, but I think he has the start to a arcade machine and I might be able to get the code for you if you wanted to look over it.
Re: Arduino Uno
WOW, that looks pretty awesome Perr! Question though, I notice it has controllers on both sides. Does the screen flip allowing the other person to view it as they should? I'm assuming it does.
Re: Arduino Uno
Good question... I think player 2 just has to play upside down.
I saw another arcade in a barrel where both sets of controls were on one side..
I originally thought that one would be better because the players wouldn't be bumping shoulders while playing, but now that you mention it, playing upside down might be worse.
I saw another arcade in a barrel where both sets of controls were on one side..
I originally thought that one would be better because the players wouldn't be bumping shoulders while playing, but now that you mention it, playing upside down might be worse.