Show Posts
Pages: 1 ... 91 92 [93] 94 95 ... 242
1381  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.
1382  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.
1383  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.
1384  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.
1385  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));
  }
}
 
1386  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);
      }
    }
  }

1387  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.
1388  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.
1389  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");
   
   }
1390  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);
      }
    }
  }




1391  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.
1392  Using Arduino / Programming Questions / Re: Need some array help on: December 11, 2013, 10:16:40 pm
Your problem lies in your IF statement. if(temperaturearray[ i ] > hottest) Your storing the first element of the array into hottest "hottest = temperaturearray[0]; " and your telling your code to go through and see which is the highest value, but your not telling it what to do when the highest value is at temperaturearray[0]. So by changing "if(temperaturearray[ i ] > hottest)" to "if(temperaturearray[ i ] >= hottest)", it does what you want it to.

The following is how I tested your code.
Code:
float temperaturearray[]  = {480.0, 30.0, 500.0, 74.0, 80.0}; // 2
float temperaturearray1[]  = { 74.0, 80.0,480.0, 30.0, 500.0}; // 4
float temperaturearray2[]  = {500.0, 74.0, 80.0,480.0, 30.0}; // 0
/* greatest temperature stored in largest */
float hottest = 0;
int currentlargestindex = 0;
int previouslargestindex = 0;

void setup()
{
  Serial.begin(9600);
  highestTemperature(temperaturearray);
  highestTemperature(temperaturearray1);
  highestTemperature(temperaturearray2);
 
}

void loop() { }

float highestTemperature(float temperaturearray[])
{
  int arraylength = 5;
  hottest = temperaturearray[0];
  previouslargestindex = currentlargestindex;
  Serial.print("previous largest index = ");
  Serial.println(previouslargestindex);
 
  for(int i = 0; i < arraylength; i++) //loops through the array
  {
    if(temperaturearray[i] >= hottest) //looks for any numbers larger then the current largest
    {
     hottest = temperaturearray[i]; //if any numbers higher then current largest, it makes that vaule the new largest value
     currentlargestindex = i; //saves the index of the largest number for use in determining where to send the motor.
    }
  }
  Serial.print("current largest index = ");
  Serial.println(currentlargestindex);
}

Output:
Before.
if(temperaturearray[ i ] > hottest)
Quote
previous largest index = 0
current largest index = 2
previous largest index = 2
current largest index = 4
previous largest index = 4
current largest index = 4

After:
if(temperaturearray[ i ] >= hottest)
Quote
previous largest index = 0
current largest index = 2
previous largest index = 2
current largest index = 4
previous largest index = 4
current largest index = 0
1393  Using Arduino / Programming Questions / Re: Need some array help on: December 11, 2013, 09:28:52 pm
Post your full code please.
1394  Using Arduino / Programming Questions / Re: String variabe array too large on: December 11, 2013, 09:18:56 pm
Dont use Strings, use char pointer arrays.

Code:
char * data[5] = {
  "Hello ", "this ", "is ", "a ", "test."};

void setup()
{
  Serial.begin(9600);
  for(int i =0; i < 5; i++)
    Serial.print(data[i]);
}

void loop() { }
1395  Using Arduino / Programming Questions / Re: arduino to android on: December 11, 2013, 05:30:53 pm
If you can get your code to work with the serial monitor, then you can get it to work (most of the time) with an Android device.
Write a code that does exactly what you want and try to control it from the serial monitor.
Pages: 1 ... 91 92 [93] 94 95 ... 242