I am trying to follow an instructable for a arduino powered game, Das Blinken Bonken. While this is my first go, I felt arrogant enough to convert it to a hockey target adding an extra target to the mix (my whole goal is to give my son and his friends something fun to shoot at). I have wired it all up (first time soldering), adapted the code posted from git hub. and ... nothing, absolutely nothing.
I am using the online ide to validate and load the code with no errors, but I am not getting the startup sequence on the 7 segment display.
The leds on the arduino is working.
Using a volt meter I can see that the 7 segment display is getting the 5 volts (As are the rest of the leds) but I don't know how to troubleshoot this.
how do I use the ide to ... test things? or validate what is running, what it does or doesn't see.
I am pasting the initializing code below in case that is helpful. with all the games it is too big.
I Am looking for advice on troubleshooting. Thanks to any takers
#include <Wire.h>
#include <Adafruit_NeoPixel.h>
#define PIN 6
const int max_pixels = 25;
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(max_pixels, PIN, NEO_GRB + NEO_KHZ800);
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_7segment matrix = Adafruit_7segment();
void (*fade_func)();
typedef struct {
void (*loop_fun)();
void (*init_fun)();
void (*menu_fun)();
} Game;
#define MENU_GAME 0
#define AIM_GAME 1
#define MINE_GAME 2
#define SPEED_GAME 3
#define FILLIT_GAME 4
#define REDVBLUE_GAME 5
#define ALG_GAME 6
#define CALIBRATE 7
//function prototypes used to be generated correctly, now we have to do them manually...
void menu();
void menu_init();
void aim();void aim_init();void aim_menu();
void mine();void mine_menu();
void spd();void spd_init();void spd_menu();
void fillit();void fillit_init();void fillit_menu();
void redvblue();void redvblue_init();void redvblue_menu();
void calibrate();void calibrate_init();void calibrate_menu();
const int game_count = CALIBRATE+1;
Game games[game_count] = {
{menu,menu_init,0},
{aim,aim_init,aim_menu},
{mine,aim_init,mine_menu},
{spd,spd_init,spd_menu},
{fillit,fillit_init,fillit_menu},
{redvblue,redvblue_init,redvblue_menu},
{calibrate,calibrate_init,calibrate_menu}};
int current_game = AIM_GAME;
const uint16_t num_pads = 5;
uint16_t pads[5];
int pad_hit;
int fader;
uint32_t fade_to;
#define PAD_M 0
#define PAD_B 1
#define PAD_L 2
#define PAD_R 3
#define PAD_BL 4
#define PAD_M_PIX 23
#define PAD_B_PIX 22
#define PAD_L_PIX 20
#define PAD_R_PIX 21
#define PAD_BL_PIX 24
#define HIT_THRESHOLD 75
#define pad_pixel(p) (24-p)
#define COUNT_DOWN_TIME 400
#define SCORE_BLINKS 4
#define ROUNDS 4
#define LEVEL_BAR_PIXELS 20
int *points;
int points_1 = 0;
int points_2 = 0;
long color_1,color_2;
long *color;
long time = 0;
long turn;
int rounds;
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
matrix.begin(0x70);
pad_hit = -1;
set_game(MENU_GAME);
}
void loop() {
(*games[current_game].loop_fun)();
}
//------- UTILS -------------
void clear_all() {
matrix.clear();
for(int i=0;i<max_pixels;i++) {
strip.setPixelColor(i, 0);
}
matrix.writeDisplay();
strip.show();
}
int pad_check() {
read_pads();
if (pad_hit >= 0) {
set_pixel_brightness(pad_pixel(pad_hit),fader,*color);
fader--;
if (fader == 0) {
strip.setPixelColor(pad_pixel(pad_hit), fade_to);
strip.show();
pad_hit = -1;
if (fade_func != 0) {
(*fade_func)();
fade_func = 0;
}
}
}
else {
if (pads[PAD_L]> HIT_THRESHOLD && pads[PAD_R] > HIT_THRESHOLD) {
set_game(MENU_GAME);
return 0;
}
for(uint16_t i=0;i<num_pads;i++) {
if (pads[i] > HIT_THRESHOLD ) {
pad_hit = i;fader = 255;
return 1;
}
}
}
return 0;
}
int game_choice;
void set_game(int game) {
if (game == MENU_GAME && current_game != MENU_GAME) game_choice = current_game;
current_game = game;
(*games[current_game].init_fun)();
}
void draw_score() {
matrix.print(*points);
matrix.writeDisplay();
}
//----------------------------------------------------------------------
// MENU
void name() {
matrix.clear();
if (games[game_choice].menu_fun == 0) {
matrix.print(game_choice);
}
else {
(*games[game_choice].menu_fun)();
}
matrix.writeDisplay();
}
void menu() {
if (pad_check()) {
if (pad_hit == PAD_L || pad_hit == PAD_R) {
game_choice+= (pad_hit == PAD_L) ? -1 : 1;
if (game_choice >= game_count) {
game_choice = 1;
}
else if (game_choice <= 0) {
game_choice = game_count -1;
}
name();
}
else {
set_game(game_choice);
}
}
}
void menu_init() {
clear_all();
color_1 = strip.Color(255,255,255);
fade_to = strip.Color(255,128,0);
color = &color_1;
strip.setPixelColor(PAD_L_PIX, 255,128,0);
strip.setPixelColor(PAD_R_PIX, 255,128,0);
strip.show();
name();
}
//----------------------------------------------------------------------
// RED VERSUS BLUE removed code due to post limit
//----------------------------------------------------------------------
// CALIBRATE
int m = 10;
int d= 1;
uint16_t counter = 0;
int current_pad;
void calibrate_init() {
counter = 0;
}
void calibrate() {
read_pads();
for(uint16_t i=0;i<num_pads;i++) {
if (pads[i] > HIT_THRESHOLD ) current_pad = i;
}
if (pads[PAD_M]> HIT_THRESHOLD && pads[PAD_R] > HIT_THRESHOLD) {
set_game(MENU_GAME);
return;
}
counter = pads[current_pad];
matrix.print(counter);
for(uint16_t i=0; i<strip.numPixels(); i++) {
if (i<counter/m) {
strip.setPixelColor(i, strip.Color(50,50,50));
}
else if (i== counter/m) { int v = (counter%m*5);
strip.setPixelColor(i, strip.Color(v,v,v));}
else {
strip.setPixelColor(i,0);
}
}
strip.show();
matrix.writeDisplay();
if (counter >= strip.numPixels() || counter == 0) d*=-1;
}
void calibrate_menu() {
matrix.writeDigitRaw(1, 0x39); // C
matrix.writeDigitRaw(3, 0x77); // A
matrix.writeDigitRaw(4, 0x38); // L
}
//----------------------------------------------------------------------
// FILL_IT removed code due to post limit
//----------------------------------------------------------------------
// AIM removed code due to post limit
//----------------------------------------------------------------------
// MINE removed code due to post limit
//----------------------------------------------------------------------
// SPEED GAME removed code due to post limit