Show Posts
Pages: 1 ... 15 16 [17] 18 19 ... 239
241  Using Arduino / Programming Questions / Re: Using RGB LED's and a potentiometer to control colour based on Kelvin scale on: July 10, 2014, 01:51:18 pm
You said you were using a slider, "potentiometer", so to get the value of that pot, you need to use the analogRead() function which returns a range from 0 - 1023. Your RGB LEDs, use 3 sets of bytes, (255, 255, 255) to determine their color. What I gave you  use the 565 format, basically RGB(255,255,255) = 565(0xFFFF). Incrementing 0xFFFF is easier than using IF/ELSE statements to increment 255,255,255.

I did try using 0x00FFFFFF, in the map function, but I didn't get the proper results I was looking for.
242  Using Arduino / Programming Questions / Re: attachInterrupt() not working for RISING and FALLING edges. on: July 10, 2014, 01:35:06 pm
Quote
How is being HIGH an event ?
Its an option that only the Due has.

Quote
Parameters

interrupt:    the number of the interrupt (int)
pin:    the pin number   (Arduino Due only)
ISR:    the ISR to call when the interrupt occurs; this function must take no parameters and return nothing. This function is sometimes referred to as an interrupt service routine.

mode:   
defines when the interrupt should be triggered. Four contstants are predefined as valid values:
LOW to trigger the interrupt whenever the pin is low,
CHANGE to trigger the interrupt whenever the pin changes value
RISING to trigger when the pin goes from low to high,
FALLING for when the pin goes from high to low.

The Due board allows also:
HIGH to trigger the interrupt whenever the pin is high.  (Arduino Due only)
243  Using Arduino / Project Guidance / Re: Minimum Safe SRAM Memory Level (for Uno)? on: July 10, 2014, 01:32:37 pm
You can attach the code file it you go under Additional Options -> Attach.

Can you put anything in the heap?
244  Using Arduino / Project Guidance / Re: how to make a Boebot controlled by arduino uno get out of a maze? on: July 10, 2014, 01:22:06 pm
right.attach(smiley-cool;   //pin

I don't think I got the memo that smiley faces could be used as pins. Could you put your code in code tags. Its the # symbol above the smiley faces.[ code ] ... [/ code]

I also see a lot of delays, no no no. Not good for your code.

245  Using Arduino / Project Guidance / Re: Minimum Safe SRAM Memory Level (for Uno)? on: July 10, 2014, 01:18:14 pm
Post your code. Did you remember to use PROGMEM or Flash memory for all your strings?
246  Using Arduino / Programming Questions / Re: Using RGB LED's and a potentiometer to control colour based on Kelvin scale on: July 10, 2014, 01:10:59 pm
Well one way to map RGB values to a linear range (1000-6000) would be to make the values into type word 0xRRGGBB or in 565 format  and scale it based on the range.

You could probably use the map() function for this like I did here.
Code:
void setup()
{
 Serial.begin(115200);
}

void loop()
{
  Serial.println(map(analogRead(A0),0,1023,0x0000,0xFFFF),HEX); // map 0-1023 to 565 color format
}

This code here does the reverse of what you want, but you could reverse engineer it.
Code:
void setup(){
Serial.begin(115200);
delay(10);
Serial.print(ConvertRGB(255,255,13), HEX);
}

void loop() {
 
}

uint16_t ConvertRGB( byte R, byte G, byte B)
{
  return ( ((R & 0xF8) << 8) | ((G & 0xFC) << 3) | (B >> 3) );
}
247  Using Arduino / Programming Questions / Re: Input and Output Tables on: July 10, 2014, 09:15:44 am
Its just in case you get a value that is not one of the case statements, this way instead of getting weird results, you can put it to something that wont cause any damage.

@CrossRoads
I wouldn't even want to write out all that.
248  Using Arduino / Programming Questions / Re: Input and Output Tables on: July 10, 2014, 09:10:47 am
Edit: you posted yours while I was typing mine.

Quote
but the problem i see with doing division to access the array is that it lacks tuning.
You make the values yourself, so you can tune it to whatever you want.

As for the case statement example:

Code:
switch(rpm_val)
{
  case 800 . . . 899: // i cant remember if the ellipsis need to be spaced or not. it might just be "..."
     vgt = 20;
     break;

  case 900 . . . 999:
     vgt = 35;
     break;
 
  case 1000 . . . 1099:
     vgt = 50;
     break;
  .
  . // rest of them
  .
  case 4400 . . . 4499:
     vgt = 250;
     break;

  default: // optional but good to have
    vgt = 10;
}
249  Using Arduino / Programming Questions / Re: Input and Output Tables on: July 10, 2014, 09:00:06 am
You might be able to find a common factor and just divide the RPM by it, to give you the VGT.

Or you can make an array of all the VGT values you want, and using division, you can access those values.

int VGT[37] = { 0 , 20 , 40 . . . 200};// set all values

output = VGT[rpm/100]; // 2000 / 100 = 20-> index 20 in array, 2100 / 100 = index 21 in array.

Edit:

Quote
rpm_val = analogRead(rpm);

if( rpm>= 2000 && rpm < 2100)
Why are you comparing the rpm pin to your range and not rpm_val, which of course will only have a range of 0 - 1023?
250  Using Arduino / Programming Questions / Re: Input and Output Tables on: July 10, 2014, 08:22:22 am
Case statements are another way. Or you can try to map the input values to produce the correct output values.
251  Using Arduino / Project Guidance / Re: Quizmaster on: July 09, 2014, 09:10:43 am
If your concerned with timing, then you can use interrupts, but for something like this, interrupts are overkill. Plus anything other than a Mega, will only have 2 interrupts.

In this case since you are going to be checking which person was first, stay away from the delay() function, it will be what kills your code. However if you do need some kind of delay, then you can use the millis() function to keep track of the passing time and do something when you need it to. Take a look at your example sketch Blink Without Delay, it will help you a lot.
252  Using Arduino / Displays / Re: ST7565R LCD TO AMPLIFIER CIRCUIT. PLEASE HELP!!! on: July 09, 2014, 09:01:33 am
You don't have to shout. Also this does not appear to be a LCD question, but more of a guidance question.

Quote
I have little/no experience or skill in programming and understanding stuff like this.
This may be a problem, because we are not going to write the code for you. We can provide examples, but not a fully working code that does exactly what you want. Sorry.

Quote
i also got a maxim digital potentiometer
Which one, there are multiple.

The best thing you can do is get them to work individually, then we will help you put them together. One other thing that may be a problem, I'm not sure if there is a library for that particular LCD display. You could try the ST7565 Library made by Ladyada LINK
253  Using Arduino / Programming Questions / Re: Add text file to sketch arduino on: July 09, 2014, 08:29:27 am
You can put the text, not the .txt file into PROGMEM and read it back where you need it. It's actually quite easy to do.
254  Using Arduino / Displays / Re: LCD newbie HELP! on: July 08, 2014, 11:04:33 pm
If you think the wiring will be too much of a hassle, you could get a I2C backpack that way you only need to worry about 4 pins instead of 16. Different library of course but not by that much.
255  Using Arduino / Programming Questions / Re: Serial.print() issue or maybe something else on: July 08, 2014, 08:21:18 am
Well the only thing left to do now is to start commenting out larger portions. Then once the serial monitor is working again, then you can add things in little by little.

Added:
Were you able to get the Snapshot example sketch to work?
Pages: 1 ... 15 16 [17] 18 19 ... 239