Recent Posts

Pages: [1] 2 3 ... 10
I am using custom targets for a laser tag game.  I have 4 teams.  Each target has an Arduino Nano to drive the IR receiver and RGB LED display to indicate what team hit the target last and what team has the most damage points on it.

When a team weapon hits a target it flashes the color of the team and then displays the highest scoring team color for that target.  Points are stored in an array.

some targets are stationary and others pop up for a certain amount of time.  The ones that pop up will have the score reset every time (so that the display will revert to no LED) but the score will be accumulated on another array

I will have 16 targets and want to display the combined score of all targets on 4 separate LED Displays

I have the targets working fine but have no idea how to connect all the Nanos to one Arduino to display the 4 scores

I want to use 4 TM1637   4 Digit 7 Segment Displays w/I2C, Red, Green, Blue, and Yellow.

How can I connect all 16 Nanos to the one Arduino to drive the LED displays?

Any help would be appreciated.

thank you
Deutsch / Re: EIB/KNX - Busankoppler Pro...
Last post by MC_HAMMER - Today at 04:35 am
Hallo TE2,

die Sache ist einleseoffensiv.

Einen sehr einfachen Busmonitor für KNX/EIB auf Basis des TP-UART gibt es schon.
Zugegeben der Monsterthread im KNX-User-Forum ist sehr unübersichtlich, darin verborgen steckt aber der einfache Busmonitor. Ganz ohne Library.

Code: [Select]

#ifdef __AVR_ATmega32U4__ //Universal Flush Interface, ProMicro, Leonardo

#define DEBUGSERIAL Serial      //USB
#define KNX_SERIAL Serial1      //D0,D1
//#define LED_PIN 13              //UFI STD, Aruino Leonardo
//#define LED_PIN 8               //UFI PWM
#define LED_PIN LED_BUILTIN_RX  //ProMicro (Attention: LOW = ON, HIGH = OFF)

#elif __AVR_ATmega2560__        //Interface, Arduino Mega

#define DEBUGSERIAL Serial      //D0,D1
#define KNX_SERIAL Serial1      //D18,D19
#define LED_PIN LED_BUILTIN     //Arduino Mega

#elif __SAMD21G18A__            //Multi Interface, Arduino Zero

#define DEBUGSERIAL SerialUSB   //USB
//#define KNX_SERIAL Serial       //Multi Interface
#define KNX_SERIAL Serial1      //D0,D1
//#define LED_PIN A5              //Multi Interface
#define LED_PIN LED_BUILTIN     //Arduino Zero



long lastMicros = 0;
bool dataReceived = false;
byte telegram[KNX_TELEGRAM_MAX_SIZE];
byte counter = 0;

void setup() {
 KNX_SERIAL.begin(19200, SERIAL_8E1);
 pinMode(LED_PIN, OUTPUT);

void loop() {
 if (KNX_SERIAL.available() > 0) {
   lastMicros = (long)micros();
   byte temp =;
   //        if(temp<16) DEBUGSERIAL.print("0"); //print 0 for 2 digit HEX
   //        DEBUGSERIAL.print(temp,HEX);
   //        DEBUGSERIAL.print(" ");
   telegram[counter] = temp;
   if (!dataReceived) {
     dataReceived = true;
     digitalWrite(LED_PIN, HIGH); //LED is ON is data is received
 if ((long)micros() - lastMicros >= 2000 && dataReceived) {
   //2000+ µs => end of telegram => new line
   //        DEBUGSERIAL.println("");
   dataReceived = false;
   //print usable array data
   for (byte i = 0; i < counter; i++) {
     if (telegram[i] < 16) DEBUGSERIAL.print("0"); //print 0 for 2 digit HEX
     DEBUGSERIAL.print(telegram[i], HEX);
     DEBUGSERIAL.print(" ");
   counter = 0;
   digitalWrite(LED_PIN, LOW); //turn LED off


void clearBuffer() {
 memset(telegram, 0, sizeof(telegram));

void printData() {
 byte temp = telegram[1];
 byte pa1 = telegram[1] >> 4;
 byte pa2 = telegram[1] & B00001111;
 byte ga1 = telegram[3] >> 3;
 byte ga2 = telegram[3] & B00000111;
 byte datalength = telegram[5] & B00001111;
 byte firstDateByte = telegram[7] & B00111111; //use only last 6 bits
 DEBUGSERIAL.print("PA: ");
 DEBUGSERIAL.print(pa1, DEC);
 DEBUGSERIAL.print(pa2, DEC);
 DEBUGSERIAL.print(telegram[2], DEC);
 DEBUGSERIAL.print(" GA: ");
 DEBUGSERIAL.print(ga1, DEC);
 DEBUGSERIAL.print(ga2, DEC);
 DEBUGSERIAL.print(telegram[4], DEC);
 DEBUGSERIAL.print(" Data length (bytes): ");
 if (datalength == 1) {
   DEBUGSERIAL.print(datalength, DEC); //if 1 then usable data max 6 bits, DPT, DPT, DPT, DPT ...
 } else {
   DEBUGSERIAL.print(datalength - 1, DEC); //ignore first byte because data doesn't fit in 6 bits
 DEBUGSERIAL.print(" Data (HEX): ");
 if (datalength == 1) {
   if (firstDateByte < 16) DEBUGSERIAL.print("0"); //print 0 for 2 digit HEX
   DEBUGSERIAL.print(firstDateByte, HEX);
   DEBUGSERIAL.print(" ");
 for (byte i = 1; i < datalength; i++) {
   if (telegram[7 + i] < 16) DEBUGSERIAL.print("0"); //print 0 for 2 digit HEX
   DEBUGSERIAL.print(telegram[7 + i], HEX);
   DEBUGSERIAL.print(" ");

Instead of using the String class you can define a buffer like this:

Code: [Select]

const int BUF_LEN = 5;
char letterBuf[BUF_LEN];
int letterIdx = 0;

When you read a button press the character is stored in the buffer.

Code: [Select]

  // if button pressed
  if ( swState != RELEASED )
    // set dot or dash
    char newChar = (SHORT_PRESS == swState) ? '.' : '-';


    // store character if room in buffer
    if ( letterIdx < BUF_LEN )
      letterBuf[letterIdx++] = newChar;



After converting a character the index would have to be reset to zero and the buffer cleared.

Code: [Select]

void clearBuf()
  memset(letterBuf, 0, BUF_LEN);

Your convert() function looks at every letter in the alphabet even if it already found a match.  I would rearrange things by stopping when a match is found and returning the index into the alphabet of the letter found.

Code: [Select]

// return index or -1
int convert()
  int retVal = (-1);
  int len = (sizeof(letters) / sizeof(letters[0]));

  // compare each letter
  for (int idx = 0; idx < len; idx++) {

    // if it's a match
    if (strcmp(letterBuf, (char *)letters[idx]) == 0) {
      retVal = idx;     // set index
      break;            // stop looking

    } // if

  } // for

  return (retVal);

I can't test the whole setup with the buttons but I did test some of the code by putting the following in setup().

Code: [Select]


  // debug - print alphabet
  for (int i = 0; i < 26; i++)
    int letterPos;

    // copy letter
    strcpy(letterBuf, letters[i]);

    // find letter
    letterPos = convert();
    if ( letterPos  >= 0 )
      Serial.print(" ");

    // clear buffer


It prints all the letters in the alphabet.  
Project Guidance / Re: Set up and programing LED ...
Last post by cattledog - Today at 04:30 am
I also need the LED to run at a 3% duty cycle.  I used the tone function coupled with digital write and delay microseconds (see below).  Does this code look correct. 
Not at all.

First, if you are not using the square wave (50%on--50%off) forget about using tone(). You can delete it from the sketch.

Do you want 190 Hz, or 290 Hz at 3% duty cycle?

Your math is not correct. Also, delayMicroseconds() does not take a value with a decimal point.

One period at 290 Hz = 1/290 = 3448 microseconds. 3% duty cycle on is 103 microseconds on and 3345 microseconds off.

One period at 190 Hz= 1/190 = 5263 microseconds. 3% duty cycle on is 158 microseconds on and 5105 microseconds off.

Using delay to generate the on/off times will block your program from doing anything else. You can generate the pulse using the method of the "blink without delay" example in the 02 - Digital examples of the IDE.

Another approach would be to use the TimerOne library which as a PWM function which you can set for a period and a duty cycle. It is available through the library manager.
Its common for no name Dc - Dc converters from China that even if you do run them within their maximum ratings, they get very hot , especially the inductor and the switcher chip.
Normally, if you overload a no name type converter, it will simply stop regulating, and the output voltage will drop.
The better ones will shut down either from the overload or from overheat.
Its better to buy one that has double the capacity that you need if you want reliability.
Programming Questions / Re: Two Way Traffic Light
Last post by gfvalvo - Today at 04:20 am
Actually, delay and interrupt are not wrong for this simple assignment.
Don't think I agree. Sure, pressing the button will trigger the ISR which will then "know" what has happened. But, there's no way for the ISR to tell the main code in loop() to abandon its current task and start at the beginning --- because it's stuck in a delay(). At best, the main code could only check a flag from the ISR after the delay() is over.

If by reading data sent to the Serial Monitor you mean interpreting what the numbers mean, that's all up to your code. For instance, it's good practice to tag your variables before you print them - something like:

Serial.print("The value of X is: ");

If you don't know much about the Serial.print function, the first line simply prints a string (the term inside quotes) and the second prints the actual data from the variable.

Open the monitor with 'Ctrl' + 'M'.
Project Guidance / Re: need two use different Bau...
Last post by TomGeorge - Today at 04:14 am
Is this to do with this posting?


Tom... :)
Portugues / Re: Compatibilidade do sensor ...
Last post by viniciusantonio - Today at 04:05 am
Caro Luis Silva. No forum em portugues acredito que seja sim o meu primeiro post, pis postei a mesma duvida no fórum em lingua inglesa.

Desconhecia as regras no tocante ao inserir códigos fonte, vou me informar sobre isso.

Agradeço pela ajuda em relação a minha dúvida sobre a biblioteca do sensor.

General Electronics / Re: Common sizes of smd compon...
Last post by xl97 - Today at 04:03 am
Dont forget 0805.
100% correct! :)
Pages: [1] 2 3 ... 10