Ruud van der Meer
Published © LGPL

Talking Bingo computer.

This is a talking Bingo computer made with a Arduino Nano Every. It can be set for 75, 90 and more.. Has 3 screens.

AdvancedFull instructions provided325
Talking Bingo computer.

Things used in this project

Story

Read more

Schematics

Schematic universal IO board for NANO

Easy connect parts to a NANO

Front universal IO for the NANO

Easy connect to a NANO

Code

Talking Bingo Computer

C/C++
Talking Bingo Computer
// V9 test, werkt goed MP3 print via de Serial1 poort via RX XT.
//
// V8 Omgezet naar een NANO every ivm te weinig geheugenruimte. Werkt in 1 keer goed op de Every. geen SW wijziging!
// Voor every kleine serial timing aanpassing.
// Kies Arduino Every, register elmulation NONE(ATMEGA4809)
//
// Werkt PRIMA 5 oktober 2022
// RM 1e test Bingo Stuurt de LED display en de Neoleds aan, I2C keyboard. Werkt OKE. 26 sept 2022.
// V4 met rotary

// MP3 muziek print op  -> RX en TX via 1:1 kabel naar MP3 print. (NANO Every)

#include <TM1637Display.h>
#include <EEPROM.h>

int povol  = 0;// potmeter volume
int oldvol = 0;// vorige waarde

TM1637Display seg7disp(4, 2);//CLK - DIO

#include <FastLED.h>          // https://github.com/FastLED/FastLED
#define LPIN1       A2        // 44 leds Nummer 2 cijfers - 7 segment
#define LPIN2       A3        // 90 leds Nummers 1-90
#define BRIGHTNESS  40
#define LED_TYPE    NEOPIXEL
#define COLOR_ORDER RGB
CRGB leds[2][90];// aantal strips, aantal led per strip.
CRGBPalette16 currentPalette;
TBlendType    currentBlending;

#include <Rotary.h>   // Rot. encoder
#define ROTAA   5 // rotating SW
#define ROTAB   6 // idem
#define GND     9 // kunstmatige ground
Rotary rota = Rotary(ROTAA,ROTAB);

#define Key_Speel  3  //NW Bingo nummer
#define Key_Reset  7  //Reset spel
#define VPotm      A0 // Volume potmeter
#define LEDPin     8  // de LED

bool Key1;
bool Key2;
bool LKey1 = HIGH;
bool LKey2 = HIGH;
bool PP = LOW; // Play/Pauze pauze=1

#include <Keypad_I2C.h>
#include <Wire.h>
#define I2CADDR 0x21 // A0=1 rest=0

// I2C Keyboard 4x4
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {0, 1, 2, 3}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 5, 6, 7}; //connect to the column pinouts of the keypad
Keypad_I2C I2CKey(makeKeymap(hexaKeys),rowPins,colPins,ROWS,COLS,I2CADDR); // row - col

byte BingoMax;// hoogste NR
byte BingoNr;  // Nummer hoogste uitgegeven nr
byte BingoLast;// Laatste getrokken getal
byte BingoDnr; // nummer wat wordt weergegeven

//   getal:                0 1 2 3 4 5 6 7 8 9 
byte BIGarray[8][10] =  { {1,0,1,1,0,1,1,1,1,1,},    //segm 0
                          {1,1,1,1,1,0,0,1,1,1,},    //segm 1
                          {1,1,0,1,1,1,1,1,1,1,},    //segm 2
                          {1,0,1,1,0,1,1,0,1,1,},    //segm 3
                          {1,0,1,0,0,0,1,0,1,0,},    //segm 4
                          {1,0,0,0,1,1,1,0,1,1,},    //segm 5
                          {0,0,1,1,1,1,1,0,1,1,},    //segm 6
                          {0,0,0,0,0,0,0,0,0,0,},    //segm 7
  };

void setup() {
randomSeed(analogRead(A7));
Serial.begin(115200);delay(100);
//Serial.println("\nRM - Bingo Computer.");
  Wire.begin();
  I2CKey.begin();
  rota.begin(true);  // Rotary met pullup aan.
  pinMode(LEDPin, OUTPUT);digitalWrite(LEDPin, LOW);
  pinMode(GND , OUTPUT);  digitalWrite(GND, LOW);
  pinMode(Key_Speel, INPUT_PULLUP);// Pullup op alle ingangen
  pinMode(Key_Reset, INPUT_PULLUP);
BingoMax=EEPROM.read(100); // Max nummer wat wordt gespeeld
seg7disp.setBrightness(0x07);// 1-7
seg7disp.showNumberDec(BingoMax,false, 4, 4); 
FastLED.setMaxPowerInVoltsAndMilliamps(5,450);// Limit draw to 450mA at 5V of power draw
// Initialize 2 strings leds.LEDs
FastLED.addLeds<LED_TYPE, LPIN1 >(leds[0], 44);// op A2
FastLED.addLeds<LED_TYPE, LPIN2 >(leds[1], 90);// op A3    
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND;
Serial1.begin(9600);delay(1000);
Setvol(15); // Half volume
PlaySound(000);// starttune Tring
NumDisp();
Serial.println("RM BingoMachine SW V9 Okt 2022.");
delay(2000);// effe wachten
}

void loop() {
Zetvol();// Set volume als er een verandering is.
KeyIn();// Key in
}

void KeyIn(){
unsigned char result = rota.process();
if (result) {Serial.print(result == DIR_CW ? "R\n" : "L\n");// Serial.println(result); 
if (result == 16) {BingPlus();}// R
if (result == 32) {BingMin();} // L
}
Key1 = digitalRead(Key_Speel);if(Key1==LOW){delay(10);//debounce
Key1 = digitalRead(Key_Speel);if((Key1==LOW)&&(LKey1==HIGH)) {Blink();BingNext();}}LKey1=Key1;//
Key2 = digitalRead(Key_Reset);if((Key2==LOW)&&(LKey2==HIGH)) {Blink();EEPROMwis();}LKey2=Key2;//

char KBKey = I2CKey.getKey();//  Serial.println(customKey);
if (KBKey != NO_KEY){Blink();//    Serial.println(KBKey);
switch(KBKey) {
case '0':  PlaySound(123); break;// Omroepbericht tune
case '1':  PlaySound(145); break;// Muziek AvD Bingo
case '2':  PlaySound(146); break;// Muziek AvD Bimbam
case '3':  PlaySound(147); break;// Cocktail trio
case '4':  PlaySound(136); break;// AvD bing lang
case '5':  PlaySound(137); break;// AvD attentie daar gaan we
case '6':  PlaySound(140); break;// AvD waar ben ik aan begonnen
case '7':  PlaySound(130); break;// er is een bingo gevallen
case '8':  PlaySound(131); break;// bingo
case '9':  PlaySound(133); break;// valse bingo
case 'A':  randomSeed(micros());PlaySound(random(150,250));break;// random nummer
case 'B':  PlaySound(148); break;// JM Wakkerworden
case 'C':  PlaySound(000); break;// jingle
case 'D':  PlaySound(EEPROM.read(BingoDnr)); break;
case '*':  PlayMuz();break;//START 
case '#':  PauzMuz();break;//STOP  
}
}
}

void NumDisp(){// op het nummerveld
clearLEDs(1,90);BingoLast=EEPROM.read(101);
for (byte i=0;i < BingoMax; i++) {
byte xx=EEPROM.read(i);
//Serial.print("=Nr ");Serial.print(i);Serial.print(" Getal ");Serial.println(xx);
leds[1][xx-1].r = 10;leds[1][xx-1].g = 10;leds[1][xx-1].b = 60;}
leds[1][BingoLast-1].r = 250;// laatste in rood
FastLED.show();   
}

void BigNum(byte getal) {// het BIG 7seg display
clearLEDs(0,44);
  for (byte s = 0; s < 8 ; s++){
    byte u = BIGarray[s][getal%10];          //Serial.println(u);
    byte j = (s*3) + u -1; if (u==1) {led3(j);}
if (getal/10 > 0){u = BIGarray [s][getal/10]; j = (s*3) + u +21; if(u==1) {led3(j);}}
    }
FastLED.show();
}

void led3(int j){leds[0][j].g = 50;leds[0][j+1].g = 50;leds[0][j+2].g = 50;}

void BigNumFun(){
for (byte i=0;i<15;i++){
clearLEDs(0,44);
byte y=i*3;
leds[0][y].r = 50;leds[0][y+1].g = 50;leds[0][y+2].b = 50;
FastLED.show(); delay(30);
}
} 

void VulLEDs1(uint8_t colorIndex) {
  for(byte i = 0; i < BingoMax; i++) // 75 of 90 leds
   {leds[1][i] = ColorFromPalette(currentPalette,colorIndex,30,currentBlending);colorIndex += 3;}
FastLED.show();   
}

void BingNext(){
if (BingoNr < BingoMax-1) {
BingoNr=0;
for (byte xx=0; ((EEPROM.read(xx) > 0)||(xx > 90))  ; xx++) {BingoNr=xx+1;}//Serial.print("Het Nr ");Serial.println(BingoNr);}
BingoRND();
EEPROM.update(BingoNr,BingoLast);
EEPROM.update(101,BingoLast);
BingoDnr=BingoNr;
BigNumFun();
Dnum(BingoNr);
NumDisp();
PlaySound(BingoLast);
}
else {PlaySound(121);}// eind bleepje
}

void BingPlus(){if (BingoDnr<BingoNr) {BingoDnr++;Dnum(BingoDnr);}}

void BingMin(){if (BingoDnr> 0) {BingoDnr--;Dnum(BingoDnr);}}

void Dnum(byte NR){
byte xx=EEPROM.read(NR);
seg7disp.showNumberDecEx(NR+1,0x40,false, 2, 4);
seg7disp.showNumberDec(xx,false, 2, 2); 
Serial.print("N=");Serial.print(NR+1);Serial.print("/");Serial.println(xx);
BigNum(xx);
}

void BingoRND(){
RND();// Random getal
bool F=false;
while (F==false) {
for (byte i=0;i < BingoMax; i++) {F=true;if (EEPROM.read(i)== BingoLast){F=false;i=BingoMax;}}
if (F==false) {RND();}
}
}

void RND(){randomSeed(micros());BingoLast = random(1, BingoMax+1);Serial.print("RND: ");Serial.println(BingoLast);}

void EEPROMwis() {for(byte i=0;i < 90; i++) {EEPROM.update(i,0);}
clearLEDs(1,90);
if (BingoMax==40) {BingoMax=50;}// toggle Bingomax
else if (BingoMax==50) {BingoMax=60;}
else if (BingoMax==60) {BingoMax=75;}
else if (BingoMax==75) {BingoMax=90;}
else if (BingoMax==90) {BingoMax=40;}
else                   {BingoMax=90;}
EEPROM.update(100,BingoMax);
EEPROM.update(101,0);
seg7disp.showNumberDec(BingoMax,false, 4, 4);
VulLEDs1(50);delay(2000);clearLEDs(1,90);
seg7disp.showNumberDec(0,false, 2, 4);
seg7disp.showNumberDec(0,false, 2, 2); 
BingoLast=0;
NumDisp();
BingoDnr=0;
BingoNr=0;
clearLEDs(0,44);
Serial.println("WIS");// wis mem
}

void clearLEDs(byte LS,byte NR){for (byte i = 0; i < NR; i++) {leds[LS][i] = CRGB::Black;} FastLED.show();}

void Blink(){digitalWrite(LEDPin,HIGH);delay(50);digitalWrite(LEDPin, LOW);}

// play number xx uit subdir "01"
void PlaySound(byte numm){byte code1[] = {126,4,66,01,(numm),239};Serial1.write(code1,6);delay(50);
Serial.print("Speel: ");Serial.println(numm);
}

void Zetvol(){
povol=analogRead(VPotm);
if ((povol > oldvol+33)||(povol < oldvol-33)) {Setvol(povol/33);oldvol=povol;
Serial.println(povol/33);
}
}

//volume, bereik: 0-30
void Setvol(byte vol){byte code1[] = {126,3,49,(vol),239}; Serial1.write(code1,5);delay(50);}

//void StopMuz() {byte code1[] = {126,2,14,239}; Serial1.write(code1,4);delay(250);} 

// PLAY muziek
void PlayMuz() {if (PP==HIGH) {byte code1[] = {126,2,1,239}; Serial1.write(code1,4);delay(250);PP=LOW;}}

// PAUZE muziek
void PauzMuz() {byte code1[] = {126,2,2,239}; Serial1.write(code1,4);delay(250);PP=HIGH;}

// EINDE program.

Schematic universal IO board for NANO

Tcl
Easy connect parts to a NANO (Every)
No preview (download only).

Credits

Ruud van der Meer

Ruud van der Meer

0 projects • 2 followers

Comments