Go Down

Topic: multiple variables from Max to Serial.read() (Read 4 times) previous topic - next topic

admin

Tom

thanks a lot for your contribution.
Since I've starting to use PD to teach i've see some of your work, congratulations.


Just a little comment on the code issue... We will  release into the wild a new version of arduino which
supports processors with 16K of code... this will solve most of the problems.

Official launch I think will be at Ars Electronica but some betas will be available much earlier.

I'm porting the bootloader right now :)

massimo

eelke

tof, thank you very much! I'll be checking the working of this on monday and will tell how things went.

ccdust

this might also help
Code: [Select]
#include <avr/eeprom.h>

int adress;
int var;
int numadress;
int prekinitve;
long previousMillis = 0;        // will store last time LED was updated
long interval = 300000;  
void setup() {
   beginSerial(9600);        // use the serial port to send the values back to the computer
   Serial.println("Termometer v 1.0");
   Serial.print("Incializacija ");
   numadress=eeprom_read_byte(0);
   Serial.print("*");
   adress=numadress+1;
   Serial.print("*");
   eeprom_write_byte((unsigned char *)adress, (analogRead(0)-556)/2); // fill each address with its own value
   Serial.print("*");
   eeprom_write_byte((unsigned char *)0, adress); // fill each address with its own value
   Serial.println("*");
}

void loop()
{
 if (millis() - previousMillis > interval) {
   previousMillis = millis();   // remember the last time we blinked the LED
   numadress=eeprom_read_byte(0);
   adress=numadress+1;
   eeprom_write_byte((unsigned char *)adress, (analogRead(0)-556)/2); // fill each address with its own value
   //Serial.print("merjeno=");
   //Serial.println((analogRead(0)-556)/2);
   //Serial.print("naslov=");
   //Serial.println(adress);
   eeprom_write_byte((unsigned char *)0, adress); // fill each address with its own value
 }

 if (Serial.available() > 0) {
   if(Serial.read()==49)
     while(prekinitve < numadress+2)
     {
       var = eeprom_read_byte((unsigned char *) prekinitve);
       Serial.print("adresa[");
       Serial.print(prekinitve);
       Serial.print("]=");
       Serial.println(var);
       prekinitve++;
     }

 }
 if (prekinitve == numadress+2)
 {
   prekinitve=0;
 }
}

Go Up