Show Posts
Pages: 1 ... 45 46 [47] 48 49 ... 196
691  Using Arduino / Project Guidance / Re: Daft Punk Thomas helmet programming on: December 16, 2013, 03:50:57 pm
DIN; CS; CLK these need to be connected to the nano. Din = 12, CS = 10, CLK = 11.
Perhaps you have something wired wrong.

Try this sketch to test your DMs.
Code:
//We always have to include the library
#include "LedControl.h"

/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn
 pin 11 is connected to the CLK
 pin 10 is connected to LOAD
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(12,11,10,1);
LedControl lcs=LedControl(7,6,5,1);

/* we always wait a bit between updates of the display */
unsigned long delaytime=100;

void setup() {
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
  lcs.shutdown(0,false);
  /* Set the brightness to a medium values */
  lcs.setIntensity(0,8);
  /* and clear the display */
  lcs.clearDisplay(0);
}

/*
 This method will display the characters for the
 word "Arduino" one after the other on the matrix.
 (you need at least 5x7 leds to see the whole chars)
 */
void writeArduinoOnMatrix() {
  /* here is the data for the characters */
  byte a[5]={B01111110,B10001000,B10001000,B10001000,B01111110};
  byte r[5]={B00111110,B00010000,B00100000,B00100000,B00010000};
  byte d[5]={B00011100,B00100010,B00100010,B00010010,B11111110};
  byte u[5]={B00111100,B00000010,B00000010,B00000100,B00111110};
  byte i[5]={B00000000,B00100010,B10111110,B00000010,B00000000};
  byte n[5]={B00111110,B00010000,B00100000,B00100000,B00011110};
  byte o[5]={B00011100,B00100010,B00100010,B00100010,B00011100};

  /* now display them one by one with a small delay */
  lc.setRow(0,0,a[0]);
  lc.setRow(0,1,a[1]);
  lc.setRow(0,2,a[2]);
  lc.setRow(0,3,a[3]);
  lc.setRow(0,4,a[4]);
  delay(delaytime);
  lc.setRow(0,0,r[0]);
  lc.setRow(0,1,r[1]);
  lc.setRow(0,2,r[2]);
  lc.setRow(0,3,r[3]);
  lc.setRow(0,4,r[4]);
  delay(delaytime);
  lc.setRow(0,0,d[0]);
  lc.setRow(0,1,d[1]);
  lc.setRow(0,2,d[2]);
  lc.setRow(0,3,d[3]);
  lc.setRow(0,4,d[4]);
  delay(delaytime);
  lc.setRow(0,0,u[0]);
  lc.setRow(0,1,u[1]);
  lc.setRow(0,2,u[2]);
  lc.setRow(0,3,u[3]);
  lc.setRow(0,4,u[4]);
  delay(delaytime);
  lc.setRow(0,0,i[0]);
  lc.setRow(0,1,i[1]);
  lc.setRow(0,2,i[2]);
  lc.setRow(0,3,i[3]);
  lc.setRow(0,4,i[4]);
  delay(delaytime);
  lc.setRow(0,0,n[0]);
  lc.setRow(0,1,n[1]);
  lc.setRow(0,2,n[2]);
  lc.setRow(0,3,n[3]);
  lc.setRow(0,4,n[4]);
  delay(delaytime);
  lc.setRow(0,0,o[0]);
  lc.setRow(0,1,o[1]);
  lc.setRow(0,2,o[2]);
  lc.setRow(0,3,o[3]);
  lc.setRow(0,4,o[4]);
  delay(delaytime);
  lc.setRow(0,0,0);
  lc.setRow(0,1,0);
  lc.setRow(0,2,0);
  lc.setRow(0,3,0);
  lc.setRow(0,4,0);
  delay(delaytime);
}

/*
  This function lights up a some Leds in a row.
 The pattern will be repeated on every row.
 The pattern will blink along with the row-number.
 row number 4 (index==3) will blink 4 times etc.
 */
void rows() {
  for(int row=0;row<8;row++) {
    delay(delaytime);
    lc.setRow(0,row,B10100000);
    delay(delaytime);
    lc.setRow(0,row,(byte)0);
    for(int i=0;i<row;i++) {
      delay(delaytime);
      lc.setRow(0,row,B10100000);
      delay(delaytime);
      lc.setRow(0,row,(byte)0);
    }
  }
}

/*
  This function lights up a some Leds in a column.
 The pattern will be repeated on every column.
 The pattern will blink along with the column-number.
 column number 4 (index==3) will blink 4 times etc.
 */
void columns() {
  for(int col=0;col<8;col++) {
    delay(delaytime);
    lc.setColumn(0,col,B10100000);
    delay(delaytime);
    lc.setColumn(0,col,(byte)0);
    for(int i=0;i<col;i++) {
      delay(delaytime);
      lc.setColumn(0,col,B10100000);
      delay(delaytime);
      lc.setColumn(0,col,(byte)0);
    }
  }
}

/*
 This function will light up every Led on the matrix.
 The led will blink along with the row-number.
 row number 4 (index==3) will blink 4 times etc.
 */
void single() {
  for(int row=0;row<8;row++) {
    for(int col=0;col<8;col++) {
      delay(delaytime);
      lc.setLed(0,row,col,true);
      lcs.setLed(0,row,col,true);
      delay(delaytime);
      for(int i=0;i<col;i++) {
        lc.setLed(0,row,col,false);
        lcs.setLed(0,row,col,false);
        delay(delaytime);
        lc.setLed(0,row,col,true);
        lcs.setLed(0,row,col,true);
        delay(delaytime);
      }
    }
  }
}

void loop() {
 // writeArduinoOnMatrix();
 // rows();
 // columns();
  single();
}
692  Using Arduino / Project Guidance / Re: Daft Punk Thomas helmet programming on: December 16, 2013, 03:25:00 pm
I have the same library, Im using my nano and your sketch. I only have two DM, but I am able to see something. However, I ran a test using your same pin setup, and both DMs work.

I looked over your code, and other than confuse me, it seems your loop is not checking the buttons. It also could just be the confusion on my end, not knowing where the buttons are, or why your using while loops to check them, and not IF statements.
But other than that,  it seems to work. Could you show me a video or picture of whats happening on your end?
693  Using Arduino / Project Guidance / Re: Transmitting logged data from Arduino Uno to computer on: December 16, 2013, 01:35:59 pm
You need to write and give them the processing code.
694  Using Arduino / Project Guidance / Re: Daft Punk Thomas helmet programming on: December 16, 2013, 01:34:36 pm
Try all three and see which works. If your using MAX7219 chip, you can cascade them. No need for seperate pins.
695  Using Arduino / Project Guidance / Re: Daft Punk Thomas helmet programming on: December 16, 2013, 03:58:38 am
The example sketch should be in the ledcontrol folder, it should be there.
696  Using Arduino / Project Guidance / Re: Daft Punk Thomas helmet programming on: December 16, 2013, 03:20:00 am
What library are you using? If it has an example sketch, it should tell you want pins need to be connected.
697  Using Arduino / Project Guidance / Re: Transmitting logged data from Arduino Uno to computer on: December 15, 2013, 12:36:49 am
You probably may want to look into Processing. It's a program similar to the Arduino IDE, and you can use Bluetooth to connect and display data. One catch, Processing and Arduino may be similar, but Processing has its own Forum, so no one over here will really know how to help you, unless they've used it themselves.

You can get a Bluetooth shield or you can get a regular HC-05 or 06 module. I myself got a JY-MCU BT module and so far, no problems.
698  Using Arduino / Project Guidance / Re: Double press button for on/off function with debounce on: December 13, 2013, 01:38:31 am
The two codes I gave should work. The first one should toggle the LED when double clicked, and the second code shows you how to create a 1 Hz pulse @ 50% duty cycle.

Try the first code again, I added a new line that I forget to mention. Sorry about that. Make sure you button is wired properly so it's normally low then when pressed, goes high.
699  Using Arduino / Project Guidance / Re: Double press button for on/off function with debounce on: December 12, 2013, 03:59:58 pm
Look at the example sketch Blink without delay.

Its quite simple. Just two while loops, comparing time to a set value. ( two if you want a duty cycle other than 50%)

Added:
Even more simple 50% duty cycle 1Hz generator
Code:
long time1 = 0;

void setup(){
pinMode(13,OUTPUT);
}

void loop() {
  if(millis() - time1 > 1000)  // 1 second = 1 Hz
  {
     time1 = millis();
    digitalWrite(13, !digitalRead(13));
  }
}
 
700  Using Arduino / Project Guidance / Re: Double press button for on/off function with debounce on: December 12, 2013, 03:52:35 pm
Code works, just had to change a few things.

Code:

byte ButtonPin = 2; //digital pin 2
byte LED = 6;

int button = LOW;
int lastButtonState = LOW;
int type,lastType=0;
long time=0;
int flagged = 0;
long newT=0;
int output = 0, lastOut;
int cnt=0;

long lastDebounceTime = 0; 
long debounceDelay = 50;



void setup() {
  pinMode(LED, OUTPUT);
  pinMode(ButtonPin, INPUT);
  Serial.begin(9600);
  Serial.println("ready");
}

void loop() {
  button = digitalRead(ButtonPin);
  if (button != lastButtonState) {
    lastDebounceTime = millis();
    lastButtonState = button;
    time = millis();
  }

  while( millis() - time < 1500){
    type = check(time);
  }

  if(type != lastType){
    lastType = type;
    Serial.println(type);
    if(type == 2) digitalWrite(LED, !digitalRead(LED));
  }
  type = 0;
}

int check(long time){
  newT=0; //cnt = 0;
  if ((millis() - lastDebounceTime) > debounceDelay) {
    newT=(millis() - time);
    if(newT < 500){
      button = digitalRead(ButtonPin);

      if(button == HIGH)
      {
        if(!flagged){
          cnt++;
          flagged = 1;
          output = cnt;
        }
      }
      else {
        flagged = 0;
      }
    }
    else {
      cnt=0;
      if(output != lastOut){
        lastOut = output;
        return output;//Serial.println(cnt);
      }
    }
  }

701  Using Arduino / Project Guidance / Re: Double press button for on/off function with debounce on: December 12, 2013, 03:23:46 pm
Take a screen shot of your circuit, I can't see  it.
702  Using Arduino / Programming Questions / Re: arduino to android on: December 12, 2013, 10:37:53 am
Android to arduino works, but arduino to android does not.
Do you get anything at all from the arduino, even garbage?
What app are you using ? What you could try, is use a program called Putty, if your arduino is sending anything out, putty should be able to show it.
703  Using Arduino / Programming Questions / Re: Multiple If else Help on: December 11, 2013, 10:56:09 pm
You should really put your code into the proper format, it makes it easier to read and understand.

Aside from that, I would suggest you make, the following into a function, again, so it is easier to read and understand.
Quote
   digitalWrite(relay, HIGH);     // switch off relay
   digitalWrite(PowerRed, HIGH); // Turn Red RGB Light Trigger On
   digitalWrite(PowerBlue, LOW); // Turn Blue RGB Light Trigger Off
   digitalWrite(PowerGreen, LOW); // Turn Green RGB ligght Trigger Off

Also I recommend you not use the delay function and look at the example sketch "Blink without Delay".


This should and the rest, should be in brackets { }.
Quote
(Irms > LightSensorB);// be the trigger
 
   digitalWrite(relay, HIGH);     // switch off relay
   digitalWrite(PowerRed, HIGH); // Turn Red RGB Light Trigger On
   digitalWrite(PowerBlue, LOW); // Turn Blue RGB Light Trigger Off
   digitalWrite(PowerGreen, LOW); // Turn Green RGB ligght Trigger Off
   if ( triggered == 0 )
   {
    triggered=1;
     delay(RelayDelayA);                      // wait for 20 seconds be checking state of current
   Serial.println("delay1 Test");
   
   }
704  Using Arduino / Project Guidance / Re: Double press button for on/off function with debounce on: December 11, 2013, 10:33:34 pm
Try this sketch.

Code:
byte ButtonPin = 2; //digital pin 2

int button = LOW;
int lastButtonState = LOW;
int type,lastType=0;
long time=0;
int flagged = 0;
long newT=0;
int output = 0, lastOut;
int cnt=0;

long lastDebounceTime = 0; 
long debounceDelay = 50;



void setup() {
  //pinMode(LEDpin, OUTPUT);
  pinMode(ButtonPin, INPUT);
  Serial.begin(9600);
  Serial.println("ready");
}

void loop() {
  button = digitalRead(ButtonPin);
  if (button != lastButtonState) {
    lastDebounceTime = millis();
    lastButtonState = button;
    time = millis();
  }

  while( millis() - time < 1500){
    type = check(time);
  }

  if(type != lastType){
    lastType = type;
    //Serial.println(type);
    switch(type){
    case 0: 
      break;
    case 1:
      Serial.println("pressed 1 time(s)");
      break;
    case 2:
      Serial.println("pressed 2 time(s)");
      break;
    case 3:
      Serial.println("pressed 3 time(s)");
      break;
    }
  }
  type = 0;
}
 
int check(long time){
  newT=0;
  if ((millis() - lastDebounceTime) > debounceDelay) {  // debounce button
    newT=(millis() - time);

    if(newT < 500) // check if button is pressed within half a second
    {
      button = digitalRead(ButtonPin);

      if(button == HIGH)
      {
        if(!flagged) // latch + lockout  that prevents cnt to increase when button is held
        {
          cnt++;
          flagged = 1;
          output = cnt;
        }
      }
      else {
        flagged = 0;
      }
    }
    else {
      cnt=0;
      if(output != lastOut) // prevents continuous stream of values, and only when the value changes, display it.
      {
        lastOut = output;
        return output;//Serial.println(cnt);
      }
    }
  }




705  Using Arduino / Programming Questions / Re: String variabe array too large on: December 11, 2013, 10:22:28 pm
The Arduino has issues with Strings, so we try to steer people away from using them, and get them into the habit of using char arrays instead.
Pages: 1 ... 45 46 [47] 48 49 ... 196