Loading...
  Show Posts
Pages: 1 ... 36 37 [38] 39 40 ... 48
556  Using Arduino / LEDs and Multiplexing / Re: Help needed with button assignment on: July 06, 2012, 05:40:24 pm
My recommendation in that you should investigate finite ste machine and implement one for this assignment. You are going down a blind alley if you want to scale this to more buttons.
557  Using Arduino / LEDs and Multiplexing / Re: Help needed with button assignment on: July 06, 2012, 09:22:18 am
Where exactly do you think it is waiting? It starts next(), checks for button 2. If it is not on, exits next. As per previous message, think of the speed at which this is happening.
558  Using Arduino / LEDs and Multiplexing / Re: Help needed with button assignment on: July 06, 2012, 08:37:36 am
It is a question of speed. The software is running too fast to detect the change in button 2. Think about something that is executing in less than a microsecond and you will understand if you trace the logic of what you have done.
559  Using Arduino / Programming Questions / Re: Get CPU ID on: July 05, 2012, 08:13:32 pm
The code that Nick has is just a sketch. That is just a running program...

I used it to read the signature bytes for an ATTiny that was not in his table - I don't have any special high voltage cables/tools or interfaces.
560  Using Arduino / Programming Questions / Re: Get CPU ID on: July 05, 2012, 07:09:48 pm
Have a look at Nick's info here http://www.gammon.com.au/forum/?id=11653
561  Using Arduino / Programming Questions / Re: Interrupts on: July 05, 2012, 06:08:36 pm
Do as little as possible in an isr. That means just increment or set a flag and then deal with the event in your loop. find out more info by googling it or look in the tutorials section of this website.
562  Using Arduino / Programming Questions / Re: Get CPU ID on: July 05, 2012, 05:56:51 pm
Every Atmel CPU has a different Id. This is readable from code and has been discussed in this forum before. Search the microprocessor thread.
563  Using Arduino / Programming Questions / Re: simultaneously turn on 2 led's on: July 04, 2012, 05:29:57 pm
As you have done everything else except turn both on at once, delay, then turn them off. You can do two digitalWrite together.
564  Using Arduino / General Electronics / Re: Is this an accurate way to read voltage to an LED? on: July 01, 2012, 09:46:20 pm
I think if you ask this question again you will make Grumpy_Mike more Grumpy smiley

The answer is NO. You are accurately measuring the voltage across the resistor. You need to swap the resistor and the LED. The LED has to be between the point you measure and ground.
565  Using Arduino / Programming Questions / Re: Smoothing Analog values (different numReadings) on: July 01, 2012, 03:19:30 pm
Simply remove the 'const' to make it a variable.

Code:
int numReadings = 10;
566  Using Arduino / Programming Questions / Re: Help with for loop on: July 01, 2012, 03:10:05 pm
A universal truth about computing machines is that NOTHING happens unless you explicitely make it happen, so you need to write it low if you want it low.
567  Using Arduino / Programming Questions / Re: Help with for loop on: July 01, 2012, 12:30:39 am
Code:
for (; millis() - penStart < 1000;){

There are 2 other types of loops in C, the while and do..while. The difference between the two 'while' loops is that the condition is evaluated at the top for the while loop and at the bottom for the do-while loop. Hence the do-while will execute at least once and may exit at the bottom.

What you have here is more naturally expressed as
Code:
while (millis() - penStart < 1000) {
568  Using Arduino / Programming Questions / Re: getting wrong values? on: June 30, 2012, 03:36:26 am
... but using it that way should be ok as it then becomes synonymous with value, which is a character array. I am just wondering is value[] is given the value 35 somewhere in the code. The print would be printing a character string (I assume) rather than the value of the pointer.

569  Using Arduino / Sensors / Re: DHT11 on: June 29, 2012, 10:36:50 pm
Code:
if (DHT11.humidity == DHT11.humidity+3 ){

This will never be true because the value of the humidity will never be the same as that value plus 3.

I am having trouble understanding what it is you want to have happen, so I am interpreting that you want the LED to come on if the value of humidity changes by 3 or more (whatever that means).

The key is that you need to remember what the value was the time before when you called getdata. So the code needs to look like this:

Code:
static int oldValue; // I have this as int but it needs to be the same type as DHT11.humidity

valorActual = DHT11.humidity,(iPuerto);
   
int chk = DHT11.read(iPuerto);

Serial.print("Sensor");
Serial.print(iPuerto);
Serial.print(" ");
switch (chk)
{
case 0:
Serial.println((float)DHT11.humidity,(iPuerto));
Serial.println(" % ");
Serial.println((float)DHT11.temperature,(iPuerto));
Serial.println(" o C");
break;
case -1: Serial.println(" Checksum error"); break;
case -2: Serial.println(" Time out error"); break;
default: Serial.println(" Unknown error"); break;

if (DHT11.humidity - oldvalue >= 3 ){ // new value and old value are different by more than the threshold
 digitalWrite (pinLed , HIGH);
  delay(1000);
   digitalWrite (pinLed , LOW);
 }else {
   
   digitalWrite (pinLed , LOW);
 }
oldValue = DHT11.humidity; // save the old value for next time
  }
}

The 'static' in the definition makes sure that the value remains in the memory between calls to getdata.

There are more elegant ways to do this, but this will do for the moment. smiley
570  Using Arduino / LEDs and Multiplexing / Re: need MULTIPLEXING 7 segment help on: June 27, 2012, 09:07:50 pm
Code:
void loop()
AA();
delay(1000);
BB();
delay(1000);
}

Clear is not needed in between because you set all the pins.

Also your delay(0.1) is the same as delay(0). I am surprised that it compiles, as delay expects an integer value.
Pages: 1 ... 36 37 [38] 39 40 ... 48