Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Programming Questions / Re: How to check time interval within a if condition on: March 23, 2012, 08:13:20 am
Code:

void loop() {
 
if (irrecv.decode(&results)) {
   // process data
  last_received = millis();
}
else if(millis() - last_received > interval){
//stop motors;
}


perhaps?
2  Using Arduino / Programming Questions / Re: Servo control on: March 18, 2012, 09:28:49 am
Right, sorry about that.. But index++ will be needed won't it?
3  Using Arduino / Programming Questions / Re: Servo control on: March 18, 2012, 05:01:56 am
This probably isn't right      

 token = strtok(NULL, ",");

edit, try this:

Code:


void parseBuffer() {
  if (strlen(buffer) > 0) {
    int vals[] = {0, 0, 0, 0, 0};
    byte index = 0;
    char *token = strtok(buffer, ",");
    while (token) {
      vals[index++] = atoi(token);
      token = strtok(buffer, ",");
    }
    // print vals
    for (int i = 0; i < 5; i++) {
      Serial.print(vals[i]);
      Serial.print(" - ");
    }
    Serial.println();
  }
}
4  Using Arduino / Programming Questions / Re: Atmega1280 Fast 10-bit PWM on: March 16, 2012, 03:27:17 pm
Uh, never mind, the pin is broken on the board ("made in china") for some reason.. Can't even remember using it before..

Anyway, substituing 5 with 3 solved the problem.. Thanks Mark smiley
5  Using Arduino / Programming Questions / Re: Atmega1280 Fast 10-bit PWM on: March 16, 2012, 02:48:07 pm
Checked that (TCCR5A+B) already and they look ok.

Btw, the voltage seems to be around .62 when not "max" which is around 1.2 or something.

Do you have any code for pwm on atmega1280 that is known to work? I tried a couple of different settings with little luck..

On a side note, analogWrite works.
6  Using Arduino / Programming Questions / Atmega1280 Fast 10-bit PWM on: March 16, 2012, 12:33:20 pm
Code:
void setup() {
 
  pinMode(45, OUTPUT); // Or DDRL |= _BV(PL4);
  TCCR5A = _BV(COM5B1) | _BV(WGM51) | _BV(WGM50);
  TCCR5B = _BV(WGM52) | _BV(CS50);
  OCR5B = 512;
}

void loop() { }

This isn't doing what I think the datasheet says it should be doing.. Did I forget some registers or something? Should be no prescaling with 10 bit fast pwm and pin 45 on the arduino mega set to set on bottom and clear on match..

AFAIK timer 5 port b is on pin 45 on the arduino mega.. If I set the ocr5b to 1023 the led lights up a little bit, but not much -- at all other values it's barely visible.

7  Using Arduino / Microcontrollers / Re: Likelihood of fake atmega8 on: March 14, 2012, 01:32:58 am
Code:
avrdude -p m328p -P /dev/tty.usbserial -c arduino -b 19200 -U lfuse:w:0xff:m -U hfuse:w:0xd9:m -U efuse:w:0x07:m -U flash:w:Test.hex -U lock:w:0x3E:m

Power comes from rs232-board
8  Using Arduino / Microcontrollers / Re: Likelihood of fake atmega8 on: March 13, 2012, 03:48:58 pm
@NI$HANT - you have several typos and I don't see any in my sentences so don't quite get where the hostile attitude comes from....


At any rate, I have now bricked the two atmega328ps I got from futurlec, which I don't suspect to be fake (and now I really don't think the cheap-o-hong-kong ones were either).. So most likely something else wrong, but I can't understand what is wrong.

Everything works correctly until they decide not to cooperate. The last one I remember quite clearly. Had done this several times already, but: I burned the fuses (all three of them), flash and lock bits. Avrdude says _everything_ is okay and everything is verified ok. But (I was just running this several times to see if it would fail) then it suddenly reported 0xffffff..

Could it be my custom circuit board? Avrdude on mac? Tinyisp? usb2serial board? I'm really at a loss now -- everything worked and then it didn't. If I put a new chip in it works, but stops after a while..

Btw, last time I didn't touch the board or anything between working and failure so not esd.

edit: and what I have programmed on them seems to work so maybe somehow the fuses can have gotten set to disable isp? but how would that happen? I was just arrow up and enter when it didn't work anymore :/
9  Using Arduino / Microcontrollers / Likelihood of fake atmega8 on: March 12, 2012, 10:03:59 am
I ordered 3 atmega8a-pu for the net sum of US$6.30 including shipping from china and they have been most difficult.. How likely is it that they are fake/made by someone other than atmel or me mishandling them that has caused them to become more and more difficult? Now at the point of only one of them returning an id other than 0xffffff...

The print on them is a lot weaker than the 328p's I got today and the date says october last year (ordered at the end of january)
10  Using Arduino / Programming Questions / Re: Reading last sent command from Serial on: March 12, 2012, 09:49:07 am
wildbill: nice catch smiley

Toxic: If you don't need to keep the state a simple return or break would suffice instead of keeping a variable around
11  Using Arduino / Programming Questions / Re: Reading last sent command from Serial on: March 12, 2012, 09:40:09 am
This doesn't seem to do what you think it will..

Move blinkmodeon outisde the function. It will always be set to 1 when you enter the function (probably right after you set it to 0 and the while loop ends). No way to know without the rest of the coude though...
12  Using Arduino / Programming Questions / Re: Help with Ajax on Arduino on: March 11, 2012, 04:26:48 pm
You don't _have_ to use jquery or have internet on your iphone, would make it slightly easier, but not necessary.

A quick google search for ajax request resulted in this: http://www.w3schools.com/ajax/default.asp

Which is as far as I can understand is what you want.
13  Using Arduino / Microcontrollers / Re: Programming new Atmega328-PU on: March 11, 2012, 04:24:08 pm
Btw, what I have done is buy a USB->RS232 board and build a programmer (one chip programming another I which can just take in and out). My first circuit board so pretty simple task smiley

Or you can just keep it on the breadboard and put the programs directly on the chip and don't bother with the bootloader.

I might consider using a bootloader if I can manage to program stuff wirelessly though..
14  Using Arduino / Programming Questions / Re: Help with Ajax on Arduino on: March 11, 2012, 03:46:02 pm
First thing is you would have to detect (in the sketch) that there is an ajax-request instead of the first page request. and if so just output the data instead of the whole page (don't know how the ethernet thingy works but normal would be to just change the url slightly)

You can even use jquery given that you have internet access on whatever device you are using to access the arduino (google cdn jquery)

1. Figure out how to detect wether to return page or ajax-data
2. Add jquery if you want (script tag in the sketch html output pointing to google cdn jquery)
3. Replace part of the page using jquery or normal ajax-request. Probably easier replacing just html instead of parsing json -- with jquery that would just be $.update something something

This might be easier trying it on a pc first though..

*watching amish ppl on tv.. odd*

Btw, pursuing the php on arduino route any further will not help you...
15  Using Arduino / Microcontrollers / Re: Programming new Atmega328-PU on: March 11, 2012, 03:10:37 pm
You will need to load the arduino isp, then hook up the breadboard and then burn bootloader. Then you can replace the chip if you want to and upload sketches..

Any reason you want to replace the chip?
Pages: [1] 2 3 4