Here is the video.
I have to build mine too but great job… Hum and i think i forgot to buy alim regulator… Will have to use usb rechargeable battey i think. Your baby Arduboy is great (And i like your buttons too)
Thanks for the encouragement.
I have just made another joystick game hat for the ArduBaby.
Here is the demo video:
This game hat can be used for other types of game consoles too.
E.g. I am making some ATtiny85 game console as well.
The same game hat can be used.
See this video for the ATtiny85 game console that I made.
The idea of a ‘hat’ is very cool. In addition to the joystick or buttons you could make a touch pad, use a style stylus … whatever!
Thanks for your feedback. I am thinking about adding a weather station hat and a supersonic distance measurement hat as well.
You could do a potentiometer hat for games like breakout and picovaders.
Capacitive touch can be found in this topic
Ad a photo diode to invert the screen you could edit Arduventure or Ardynia to add Boktai features or invert the screen for day night modes.
Lots of sensor hat options
@Keyboard_Camper Thanks for the suggestion.
picovaders is one of my favourite. Analog control would be great! Where I can found the source code that supports the potentiometer ?
I have successfully modified the USBasp to work at both 5V and 3.3V.
Tested burning the CAT3K boot loader onto my homemade Arduboy running at 3.3V with the serial flash in. Works fine and the serial flash survived the burn.
I spent some time figuring out how to modify my version of USBasp, so I want to share it here in case it’s useful for others.
Youtube Link:
Instructables Link:
Just published my video to show how to create the hardware and configure the software and utility of Arduboy including how to use the flash-cart utilities.
Hope it will be useful for others.
Video
Written instructions
HI am trying to modify picovaders to make use of a 10K VR to control the cannon instead of the left and right button.
The two side pins of the VR is connected to Ground and 3.3V, and the middle pin is connected to A0.
I got an issue that I cannot get a value other than 0 from the analogRead (A0) command.
I am able to get variable values of 0 to 1023 (proportional to the angle of my turn) using using the same VR and loading the simple sketch without using any Arduboy libraries below.
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println (analogRead(A0);
}
However, when I use the following sketch that I modified from the example of Arduboy Button, I keep getting 0 only from analogRead (A0);
See below. Any one knows how I can do an analogRead (A0) using the Arduboy library ?
Many thanks.
#include <Arduboy2.h>
// Make an instance of arduboy used for many functions
Arduboy2 arduboy;
// Variables for your game go here.
char title[] = "Press Buttons!";
byte x;
byte y;
// Width of each charcter including inter-character space
#define CHAR_WIDTH 6
// Height of each charater
#define CHAR_HEIGHT 8
// To get the number of characters, we subtract 1 from the length of
// the array because there will be a NULL terminator at the end.
#define NUM_CHARS (sizeof(title) - 1)
// This is the highest value that x can be without the end of the text
// going farther than the right side of the screen. We add one because
// there will be a 1 pixel space at the end of the last character.
// WIDTH and HEIGHT are defined in the Arduboy library.
#define X_MAX (WIDTH - (NUM_CHARS * CHAR_WIDTH) + 1)
// This is the highest value that y can be without the text going below
// the bottom of the screen.
#define Y_MAX (HEIGHT - CHAR_HEIGHT)
// This function runs once in your game.
// use it for anything that needs to be set only once in your game.
void setup() {
//initiate arduboy instance
arduboy.begin();
// here we set the framerate to 30, we do not need to run at default 60 and
// it saves us battery life.
arduboy.setFrameRate(30);
// set x and y to the middle of the screen
x = (WIDTH / 2) - (NUM_CHARS * CHAR_WIDTH / 2);
y = (HEIGHT / 2) - (CHAR_HEIGHT / 2);
**Serial.begin(115200);**
}
// our main game loop, this runs once every cycle/frame.
// this is where our game logic goes.
void loop() {
// pause render until it's time for the next frame
if (!(arduboy.nextFrame()))
return;
// the next couple of lines will deal with checking if the D-pad buttons
// are pressed and move our text accordingly.
// We check to make sure that x and y stay within a range that keeps the
// text on the screen.
// if the right button is pressed move 1 pixel to the right every frame
if(arduboy.pressed(RIGHT_BUTTON) && (x < X_MAX)) {
x++;
}
// if the left button is pressed move 1 pixel to the left every frame
if(arduboy.pressed(LEFT_BUTTON) && (x > 0)) {
x--;
}
// if the up button or B button is pressed move 1 pixel up every frame
if((arduboy.pressed(UP_BUTTON) || arduboy.pressed(B_BUTTON)) && (y > 0)) {
y--;
}
// if the down button or A button is pressed move 1 pixel down every frame
if((arduboy.pressed(DOWN_BUTTON) || arduboy.pressed(A_BUTTON)) && (y < Y_MAX)) {
y++;
}
// we clear our screen to black
arduboy.clear();
// we set our cursor x pixels to the right and y down from the top
arduboy.setCursor(x, y);
// then we print to screen what is stored in our title variable we declared earlier
arduboy.print(title);
**Serial.println (analogRead(A0));**
// then we finaly we tell the arduboy to display what we just wrote to the display.
arduboy.display();
}
I may be wrong, but looks like A0 is normally wired to the up button and read as a digital input with pullup, so the arduboy library may be incorrectly configuring the pin for your application and disabling analog reading (which would explain why calling analogRead always returns 0). Have you manually tried to reconfigure the pin’s registers at the end of setup to enable analog measurement with the correct mux settings and what not?
The Arduboy2 library disables the ADC to save power. Use power_adc_enable() in setup() to re-enable it.
@Cheungbx,
When posting code, please format it by starting with a line containing three backticks (usually the key below the ESC key at the top left, at least on US keyboards) followed by the letters cpp,
then your code,
then add another line with 3 more backticks:
```cpp
Your code goes here
```
I edited your previous post to add this, but please do it yourself in the future.
Thanks
Thanks @MLXXXp
This works like a charm.
I found Picovaders much easier to play with the paddle. Not sure why the number froma analogRead can only gets down from 1023 max to 13-15 but not 0 even if I turned all the way down. May be due to the redudual resistance of the VR . No problem, I can fix that using the map function. Besides Picovaders,
I have also applied this to Breakout-V and ArduboyNG (Pong). I chose A3 instead of A0,A1,A2 to avoid accidentally triggering the RGB led when you had the potentiometer turned down then power up or reset.
That’s fine. Just don’t use A4, which should be left open so it can pick up random electrical noise. This is used by the generateRandomSeed() and thus initRandomSeed() library functions.
Note, though, that A3 is the DOWN button. For sketches that eliminate the USB code using the library’s ARDUBOY_NO_USB feature, the DOWN button will trigger entry into the bootloader if pressed during power up.
Thanks for the tips. I will design for two paddles.
Paddle1 is mounted on the button hat board.
Paddlle1->X = A3
Paddlle1->Y = A2
Paddlle2->X = A1
Paddlle2->Y = A0
Paddle2 will be connected using an extension cable to the first game console to allow two players to play the Pong game, or if someone fancy writing other combat game for two players.
To think further a bit, may be we can even build a second brainless console with only buttons/paddles and OLED screen (running in parallel with the first OLED screen, just extending the same 7-pins, not sure if this will work or both OLEDs will dim out),
In order to navigate the flash-cart bootloader menu and other in-game menus (e.g. ArduboyNG (a version of PONG)), I added a tiny 8x8mm joystick like mini-switch, like the one used for the ATtiny joypad, While this sounds like a good idea, it comes with some unwanted side effects. There is a chance that someone may press the down button while the VR for A3 is turned to zero ohm to VCC. That will create a short circuit situation between ground and VCC, that may cause the battery to burn and explode in the worst case (if the battery protection circuit failed). And if you have the USB port connected to your computer, your computer may be impacted too.
I changed the circuit a bit to avoid this (see attached circuit diagram) to allow VR to be in any position without either triggering some hot buttons during boot up, or shortening the circuit between ground and VCC when someone pressed a button while the VR is turned all the way towards VCC.
After testing using a tiny program I wrote to show values of the ADC, I fixed the resistor to 10K to ground. The actual ADC value on my board ranges from 464 to 728 when I turned the VR clockwise, which is quite acceptable. To be safe I will use 470 to 720 as the input range to the mapping function. The value is still far from the value of 380 when the button is considered pressed, while still a good range to map to the output range required to move the cannon in the Picovaders game, or the bat on the Pong or Breakout game.
I tested this on Picovaders and the result is acceptable. Compared with the original versions, where I had both side of the VR tied to ground and VCC directly, the original version did not shake at all. This new version of the circuit shakes a bit. The cannon is quite stable from far left to the middle of the screen, but starts shaking back and forth by 1 pixel when its moved beyond the middle of the screen to the far end.
I tried putting in different size of capacitors across ground and the input pin (A3) , from 0.1uF, down to 10pf. That does not seem to improve the situation.
After all you won’t notice the small shaking as you will be moving the cannon back and forth.
That also reminds me of the original Space Invader arcade machines I used to play at the stores in the neighbourhood when I was still 12 years old. These had big dials and the cannon shaked like ghosts.
I liked purely because you’re using an actual ruler instead of a coin.
Electronics websites could learn from you. :P
Will you sell some complete console with keys and 2 paddles and a box to protect them ? if you do how many you could sell them ? (I ask because i like and i would buy one. Having 500 games and ability to choose controller… i like too much )
Thanks for the encouragement. I am still learning from masters like you.