Recent Posts

Pages: [1] 2 3 ... 10
1
I am using 2 74HC595 shift register for driving a 8x8 led matrix.When i am lighting up the whole first column for writing letter N the pixels are much dimmer than i am lighting the one pixel of other column for diagonal elements of N?.Can anybody help me with this?
2
Français / Re: Portable problèmes batteri...
Last post by J-M-L - Today at 07:23 am
1an ? Faites jouer la garantie, ne bricolez pas
3
Sorry, I misread your OP. So, how far should the divider rotate for 1 rev (2400 pulses) of the spindle encoder?
4
How is your switch wired?

long buttonTimer = 0;
This should be:
unsigned long buttonTimer = 0;


5
1hr 30mins
how about this:

Code: [Select]

float var = 1.30;

int hour = (int)var;

int minute = (var - hour) * 100;



This code will extract a float value to hour and minute. Of course, it does not account for seconds.
6
I programmed  to press the push button once ( long press ) to turn on the LED in the board and  press it again  (short press)  to turn off.

But i need help,
If i push button (short press or long press) no action taken care by program withing 1 minutes after LED on
same case after LED off.


Code Below

int LED1 = 12;
int LED2 = 13;
int button = 3;

boolean LED1State = false;
boolean LED2State = false;

long buttonTimer = 0;
long longPressTime = 250;

boolean buttonActive = false;
boolean longPressActive = false;

void setup() {

   pinMode(LED1, OUTPUT);
   pinMode(LED2, OUTPUT);
   pinMode(button, INPUT);

}

void loop() {

   if (digitalRead(button) == HIGH) {

      if (buttonActive == false) {

         buttonActive = true;
         buttonTimer = millis();

      }

      if ((millis() - buttonTimer > longPressTime) && (longPressActive == false)) {

         longPressActive = true;
         LED1State = !LED1State;
         digitalWrite(LED1, LED1State);

      }

   } else {

      if (buttonActive == true) {

         if (longPressActive == true) {

            longPressActive = false;

         } else {

            LED2State = !LED2State;
            digitalWrite(LED2, LED2State);

         }

         buttonActive = false;

      }

   }

}
7
Software / Re: Array....maledetti Array
Last post by Puso - Today at 07:10 am
 ;D  ;D  ;D  ;D  ;D
 C'E' L'HO FATTA!!!!!!!!!!!
Code: [Select]

#define A 2
#define B 3
#define C 4
#define D 5
#define E 6
#define F 7
#define G 8

byte pinLed[]={A,B,C,D,E,F,G};//piedini dei display
byte scrivi[16][7]={
                  {0,0,0,0,0,0,1},//scrive 0
                  {1,0,0,1,1,1,1},//scrive 1
                  {0,0,1,0,0,1,0},//scrive 2
                  {0,0,0,0,1,1,0},//scrive 3
                  {1,0,0,1,1,0,0},//scrive 4
                  {0,1,0,0,1,0,0},//scrive 5
                  {0,1,0,0,0,0,0},//scrive 6
                  {0,0,0,1,1,1,1},//scrive 7
                  {0,0,0,0,0,0,0},//scrive 8
                  {0,0,0,0,1,0,0},//scrive 9
                  {0,0,0,1,0,0,0},//scrive A
                  {1,1,0,0,0,0,0},//scrive b
                  {0,1,1,0,0,0,1},//scrive C
                  {1,0,0,0,0,1,0},//scrive d
                  {0,1,1,0,0,0,0},//scrive E
                  {0,1,1,1,0,0,0},//scrive F 
                 };
                 
byte pinL=0;//variabile per la dimensione di PINLED

byte riga=0;//variabile per la prima dimensione di SCRIVI
byte colonna=0;//variabile per la seconda dimensione di SCRIVI


void setup()
{
 Serial.begin(9600);//velocita di..........sul SERIAL MONITOR
 for(byte i=0;i<7;i++)//PER 7 volte incrementa la variabile i
    {
     pinMode(pinLed[i],OUTPUT);//mette [i]di PINLED in modalità USCITA
     digitalWrite(pinLed[i],HIGH);//appena acceso mette i pin ad uno stato ALTO (+5V)....(display Anodo Comune)
    }
}

void Avanti()
{
  for( riga=0;riga<16;riga++)//PER 16 volte ripete il ciclo riga
     {
      delay(1000);//aspetta
      for(colonna=0;colonna<7;colonna++)// all'interno del cilo  riga PER 7 volte ripete il ciclo colonna
         {
          pinL=scrivi[riga][colonna];//pinL assume il valore della riga*colonna di scrivi
          if(pinL==0){digitalWrite(pinLed[colonna],LOW);}//SE il valore di pinL è zero Spegne il led corrispondente in pinLed
          else{digitalWrite(pinLed[colonna],HIGH);}//ALTRIMENTI lo accende
         }
      }   
}   

 
void loop()
{
 Avanti();
}

8
Audio / Re: playing audio with servo
Last post by Grumpy_Mike - Today at 07:01 am
It is not working because you are using software serial. You have to use the Mega's extra UARTs using Serial1 or Serial2 or Serial3, to talk to them in software and wire the appropriate pair of pins to your sound module.
9
Project Guidance / Re: Help With The NRF24L01 Mod...
Last post by bluejets - Today at 06:59 am
Code: [Select]
/*
 
 Connections for nRF24L01 pins
 1 - GND
 2 - VCC 3.3V !!! NOT 5V
 3 - CE to Arduino pin 9
 4 - CSN to Arduino pin 10
 5 - SCK to Arduino pin 13
 6 - MOSI to Arduino pin 11
 7 - MISO to Arduino pin 12
 8 - UNUSED
 
 Connections for OLED screen pins
 GND - GND
 VCC - VCC (mine seems to work with both 5V and 3.3V
 SDA - arduino analog pin 4
 SCL - arduino analog pin 5
 
 */

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

const uint64_t pipeIn =  0xE8E8F0F0E1LL; // match this on both sides!

RF24 radio(9, 10);

// The sizeof this struct should not exceed 32 bytes
struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
  byte dial1;
  byte dial2;
  byte switches; // bitflag
};

MyData data;

unsigned long packetsRead = 0;
unsigned long lastUpdate = 0;
int packetsSec = 0;
unsigned long lastRecvTime = 0;
unsigned long drops = 0;

/**************************************************/

// writes a single line of formatted text to the screen at the current cursor position - keep it short!
void displayln(const char* format, ...)
{
  char buffer[64];
 
  va_list args;
  va_start(args, format);
  vsprintf(buffer, format, args);
  va_end(args);
 
  int len = strlen(buffer);
  for (uint8_t i = 0; i < len; i++) {
    display.write(buffer[i]);
  }
}

/**************************************************/

void setup()
{
  radio.begin();
  radio.setDataRate(RF24_250KBPS); // Both endpoints must have this set the same
  radio.setAutoAck(false); // Both endpoints must have this set the same

  radio.openReadingPipe(1,pipeIn);
  radio.startListening();

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.clearDisplay();
   
  memset(&data, 0, sizeof(MyData));

}

/**************************************************/

void recvData()

  while ( radio.available() ) {       
    radio.read(&data, sizeof(MyData));
    packetsRead++;
    lastRecvTime = millis();
  }
 
  unsigned long now = millis();
  if ( now - lastRecvTime > 1000 ) {
    drops++;
  }
}

/**************************************************/

void displayBits(byte b, int howManyBits)
{
  for (int i = 0; i < howManyBits; i++) {
    int mask = 1 << i;
    if ( b & mask )
      display.write('*');
    else
      display.write('-');
  }
}

/**************************************************/

void updateScreen()
{
  unsigned long now = millis();
  if ( now - lastUpdate > 1000 ) {
    packetsSec = packetsRead;
    packetsRead = 0;
    lastUpdate = now;
  }
     
  char buf[16];
   
  display.clearDisplay();
  display.setCursor(0,0);
  displayln("Packets = %d\n", packetsSec);
 
  displayln("%d\n", data.throttle);
  displayln("%d\n", data.yaw);
  displayln("%d\n", data.pitch);
  displayln("%d\n", data.roll);
  displayln("%d\n", data.dial1);
  displayln("%d\n", data.dial2);
 
  // draw rectangle for joystick outline
  display.drawRect(30,12, 40,40, 1);
  display.drawRect(75,12, 40,40, 1);
 
  int d1 = map(data.throttle, 0, 255, 0, 100);
  int d2 = map(data.yaw,      0, 255, 0, 100);
  int d3 = map(data.pitch,    0, 255, 0, 100);
  int d4 = map(data.roll,     0, 255, 0, 100);
 
  // draw dot for current joystick position
  display.fillRect(30+40*(d2/100.0)-3, 52-40*(d1/100.0)-3, 6,6, 1);
  display.fillRect(75+40*(d4/100.0)-3, 52-40*(d3/100.0)-3, 6,6, 1);
 
  display.setCursor(0,7*8);
   
  displayBits(data.switches, 8);
  display.write(' ');
 
  displayln("%ld drops\n", drops);
   
  display.display();
}

/**************************************************/

void loop()
{
  recvData();
  updateScreen();
}




10
Displays / Re: Which display to use (for ...
Last post by TFTLCDCyg - Today at 06:59 am
Gameduino 2 + Arduino Due

FT801 (HotMCU or Riverdi)+ STM32F407VE

FT801 (HotMCU or Riverdi) + Teensy 3.2 (or 3.6)
Pages: [1] 2 3 ... 10