how to save float value EEPROM

Hi This is Eabul. i want to save data to eeprom from press button . when TemperatureUp button press. increase float data like as 0.01> 0.02--------30.10> 30.61 and this value save to eeprom. and when TemperatureDown button press . decrease float data like as 30.60>30.59-----29.10 and update minus value eeprom and increase and decrease valud view lcd display . but when press button save int number not float. and show me lcd display int value. please help how to write and read float value from eeprom. press button. hear my code. //For Display #include // 3wire display LiquidCrystal595 lcd(4, 3, 2); // DS, ST_CP, SH_CP //For time #include #include RTC_DS1307 RTC; //for humidity #include "DHT.h" DHT dht; //for stor tempereratur and humidity #include int SetHumidity; int HumidityUp = 10; // switch up is at pin 10 int HumidityDown = 11; // switch down is at pin 11 float fix = 0.01; float settemp; // make a variable called temp float TemperatureUp = 12; // switch up is at pin 12 float TemperatureDown = 13; // switch down is at pin 13 //result view int led = 0; // led is at pin 0 void setup() { //For timer Wire.begin(); RTC.begin(); //For welcome screen lcd.begin(16,4); lcd.setCursor(0,0); lcd.print("Welcome Elab"); delay(2000); lcd.clear(); //for dht-11 pin setup dht.setup(A1); // data pin 2 } void loop() { //For tempererature up / down float temp[3]; getTemp(temp); float tempererature = temp[1]; settemp =; // read the settemp on the eeprom if(digitalRead(TemperatureUp) == 1 ) { settemp+=fix; settemp++; EEPROM.write (1, settemp); /* write the most recent settemp in eeprom data stoage*/ } else {} if(digitalRead (TemperatureDown) == 1) { settemp -= fix; settemp--; EEPROM.write (1, settemp); /* write the most recent settemp in eeprom data stoage*/ } if (tempererature >= settemp) { digitalWrite (led, 1); } else { digitalWrite (led, 0);} //else { }; lcd.setCursor(0,0); lcd.print("T:"); lcd.print(tempererature); lcd.setCursor(8,0); lcd.print ("ST"); lcd.print (settemp); lcd.print((char)223); //End tempererature controll //For humidity up / down SetHumidity =; int humidity = dht.getHumidity(); if(digitalRead(HumidityUp ) == 0 ) {SetHumidity++ ; } // add one to the settemp else {} if(digitalRead (HumidityDown) == 0) { SetHumidity--; } // Reduse settemp else { }; lcd.setCursor (0, 1); lcd.print ("CH:"); lcd.print (humidity); lcd.print ("%"); lcd.setCursor (8, 1); lcd.print ("SH:"); lcd.print (SetHumidity); lcd.print ("%"); delay (1); // wait 100 milliseconds EEPROM.write (2, SetHumidity); /* write the most recent settemp in eeprom data stoage*/ //End tempererature controll controll } //analog temperature void getTemp(float * t) { const int analogPin = 0; // replace 0 with analog pin const float invBeta = 1.00 / 3380.00; // replace "Beta" with beta of thermistor const float adcMax = 1023.00; const float invT0 = 1.00 / 298.15; // room temp in Kelvin int adcVal, i, numSamples = 5; float K, C, F; adcVal = 0; for (i = 0; i < numSamples; i++) { adcVal = adcVal + analogRead(analogPin); delay(100); } adcVal = adcVal/5; K = 1.00 / (invT0 + invBeta*(log ( adcMax / (float) adcVal - 1.00))); C = K - 273.15; // convert to Celsius F = ((9.0*C)/5.00) + 32.00; // convert to Fahrenheit t[0] = K; t[1] = C; t[2] = F; return; }

Posted by esumon 8 months ago

Programming eeprom

I have been trying to program an atmel 25040 eeprom with a superpro3000, it accepts the program,but when I click on the verfy option an error message appears. Can any one please help?

Posted by jimenazo 10 years ago

Help programming a 8 pin eeprom

Hi, can any one help on programming a atmel 25040 eeprom? I have a superpro3000. This chip accepts the program, but when i verify it a error message appears.

Posted by jimenazo 10 years ago

MPLAB and PIC16F628A, basic EEPROM functions wont work

Hello all Ive got a query about the simulator in MPLAB.  I'm using a PIC16F628A-IP and Ive written a couple of subs to run the EEPROM functions, but when I try and run the program in the simulator and observe the registers, I'm noticing that EECON1 is not accepting bit changes, and when reading from the EEPROM, i get as far as getting the correct value into W register (MOVFW EEDATA), then the next step, simply a RETURN command, for no reason wipes the W register back to 0 and hence the routine always returns a 0 Can somebody have a look and see whats going wrong, this is one of the easiest routines to write as there are so many examples on the web, Ive even used code straight from Microchip's Code Library and that didnt work either, its driving me MAD!!! All I am trying to do with the following code is simply read the EEPROM contents of address 05, display the returned contents to PORTB, wait a second, then increment the contents by 1 and resave into the EEPROM at address 05, so by rights on power up I should see FF then 00 then 01 then 02, etc, incrementing every second, on PORTB....I'm a bit of a stickler for custom keywords so sorry if its a bit confusing, makes perfect sense to me of course! ;  GENERIC PROGRAMMING HEADER  LIST P=16F628A   ; DETERMINE CORE TYPE  INCLUDE "P16F628A.INC" ; INCLUDE DEFAULT ASSEMBLY FILE FOR THIS CORE  ORG 00H     ; START PROGRAM AT LINE 0  RADIX HEX    ; ASSUME HEX UNLESS SPECIFIED  ERRORLEVEL -302  ; NO BANK WARNINGS DURING ASSEMBLY   ;  SET BURN CONIFGURATION FOR NO WDT AND INTERNAL OSC AT 4MHZ  __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF &_INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _LVP_OFF ;  CONSTANTS AND VARIABLES OPT  EQU 81H  ; OPTION REGISTER NN  EQU 02AH ; GENERAL N REGISTER FOR COUNTING DELAYS XX  EQU 02BH ; GENERAL X REGISTER FOR COUNTING DELAYS YY  EQU 02CH ; GENERAL Y REGISTER FOR COUNTING DELAYS TEMP EQU 02DH ; GENERAL TEMPORARY FOLDER 1 TMP  EQU 02EH ; GENERAL TEMPORARY FOLDER 2 FLAGS EQU 020H ; MISCELLANEOUS PROGRAM SPECIFIC FLAGS N  EQU 021H X  EQU 022H ; GENERAL TEMP STORES Y  EQU 023H ;  CUSTOM INSTRUCTIONS #DEFINE   BANK0     BCF       STATUS,RP0          ; Sel Bank 0 #DEFINE   BANK1     BSF       STATUS,RP0          ; Sel Bank 1 #DEFINE   READNVM CALL READ #DEFINE   WRITENVM CALL WRITE #DEFINE   W10MS  CALL DELAY #DEFINE   W1S  CALL DELAY1S ;----------------------------------------------------------------- ;  INITIALISE MICRO ;----------------------------------------------------------------- INIT   BANK1   CLRF  TRISB ; PORT B DEFINED ALL OUTPUTS   MOVLW 0FFH   MOVWF TRISA ; PORT A ALL INPUTS   BANK0 ;  SET TO MIMIC 16F84 BY TURNING OFF COMPARATOR   MOVLW 07H   MOVWF CMCON ;  PURGE GENERAL RAM FILES   CLRF NN   CLRF XX   CLRF YY   CLRF TEMP    CLRF TMP    CLRF FLAGS   CLRF N   CLRF X   CLRF Y   CLRF PORTA   CLRF PORTB   CLRF OPT   CLRF INTCON   ;------------------------------------------------------------------- ;  MAIN PROGRAM ;------------------------------------------------------------------- MAIN; ORIGIN   MOVLW 05   READNVM   MOVWF PORTB   W1S   MOVLW 05   MOVWF EEADR   MOVF PORTB,W   INCF W,1   MOVWF EEDATA   WRITENVM   GOTO  MAIN ;--------------------------------------------------------------------------- ;  END OF MAIN PROGRAM BODY ;---------------------------------------------------------------------------   GOTO FINISH  ; PROGRAM LOOP FALLOUT ;--------------------------------------------------------------------------- ;  SUBROUTINES ;--------------------------------------------------------------------------- ; LIST OF AVAILABLE SUBS: ; DELAY  = 10mS DELAY ; DELAY1S  = 1 sec DELAY ; WRITE  = WRITE TO EEPROM, MUST BE LOADED WITH EEDATA AND EEADR B4 ENTRY ; READ  = READ FROM EEPROM ADDRESS HELD IN W BEFORE ENTRY, RETURN RESULT IN W ;  10mS DELAY DELAY       MOVLW 0AH   MOVWF XX OUTER   MOVLW 0C7H   MOVWF YY INNER   NOP         NOP         DECFSZ  YY,1         GOTO    INNER                 DECFSZ  XX,1         GOTO    OUTER   NOP   NOP   NOP   NOP   NOP   NOP   NOP         RETURN DELAY1S   ; 100x10mS DELAYS   MOVLW  064H   MOVWF NN D1L  W10MS   DECFSZ NN,1   GOTO D1L    RETURN   WRITE       BANK1         CLRF EECON1                        BSF EECON1,WREN            ; enable write   W10MS   W10MS   BCF INTCON,GIE         MOVLW H'55'                ; magic sequence         MOVWF EECON2                       MOVLW H'AA'                          MOVWF EECON2                       BSF EECON1,WR   W10MS   W10MS             eeloop BTFSC EECON1,WR            ; wait for WR to go low         GOTO eeloop                ; not yet         BCF EECON1,WREN                    BCF INTCON,GIE           ; clear the interrupt flag         BANK0   W10MS   W10MS         RETURN READ BCF EECON1,WREN   MOVWF EEADR                ; set up eeprom address from W         BANK1   BSF EECON1,RD              ; set the read bit         BANK0   MOVFW EEDATA              ; return value in W         RETURN   ;  PROGRAM ENDS FINISH   END Note, this will probably make more sense if its copied and pasted into an ASM in MPLAB, as the tab stops and comments become more apparent THanks for looking  

Posted by whitebakecase 8 years ago

How to read uart data and write to i2c device.

// Port for the I2C #define I2C_DDR DDRD #define I2C_PIN PIND #define I2C_PORT PORTD // Pins to be used in the bit banging #define I2C_CLK 0 #define I2C_DAT 1 #define I2C_DATA_HI()\ I2C_DDR &= ~ (1 << I2C_DAT);\ I2C_PORT |= (1 << I2C_DAT); #define I2C_DATA_LO()\ I2C_DDR |= (1 << I2C_DAT);\ I2C_PORT &= ~ (1 << I2C_DAT); #define I2C_CLOCK_HI()\ I2C_DDR &= ~ (1 << I2C_CLK);\ I2C_PORT |= (1 << I2C_CLK); #define I2C_CLOCK_LO()\ I2C_DDR |= (1 << I2C_CLK);\ I2C_PORT &= ~ (1 << I2C_CLK); void I2C_WriteBit(unsigned char c) {     if (c > 0)     {         I2C_DATA_HI();     }     else     {         I2C_DATA_LO();     }     I2C_CLOCK_HI();     delay(1);     I2C_CLOCK_LO();     delay(1);     if (c > 0)     {         I2C_DATA_LO();     }     delay(1); } unsigned char I2C_ReadBit() {     I2C_DATA_HI();     I2C_CLOCK_HI();     delay(1);     unsigned char c = I2C_PIN;     I2C_CLOCK_LO();     delay(1);     return (c >> I2C_DAT) & 1; } // Inits bitbanging port, must be called before using the functions below // void I2C_Init() {     I2C_PORT &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK));     I2C_CLOCK_HI();     I2C_DATA_HI();     delay(1); } // Send a START Condition // void I2C_Start() {     // set both to high at the same time     I2C_DDR &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK));     delay(1);     I2C_DATA_LO();     delay(1);     I2C_CLOCK_LO();     delay(1); } // Send a STOP Condition // void I2C_Stop() {     I2C_CLOCK_HI();     delay(1);     I2C_DATA_HI();     delay(1); } // write a byte to the I2C slave device // unsigned char I2C_Write(unsigned char c) {     for (char i = 0; i < 8; i++)     {         I2C_WriteBit(c & 128);         c <<= 1;     }     //return I2C_ReadBit();     return 0; } // read a byte from the I2C slave device // unsigned char I2C_Read(unsigned char ack) {     unsigned char res = 0;     for (char i = 0; i < 8; i++)     {         res <<= 1;         res |= I2C_ReadBit();     }     if (ack > 0)     {         I2C_WriteBit(0);     }     else     {         I2C_WriteBit(1);     }     delay(1);     return res; }

Posted by Blixxer 3 years ago

Which Processor?

Hello everyone. I'm new here and I have a quick question about processors. I'm working on a project that requires a device to take inputs piezo buzzer elements and trigger an LED. The catch is I need a programmable chip so I can have pre-set outputs on the LEDs. I'd need something that can be rewritten (like an EEPROM) I've been thinking abuot using a PIC or a BASIC Stamp but I'd though I'd do a bit of research first.

Posted by mrpaps 11 years ago

Emergency Dash Light - Repair

Hello All - I am attempting to repair an Emergency Dash Light for a friend of mine.  It has blue LED lights it is similar to the one pictured in this link:;=USD&products;_id=11981  Initially the unit had all 4 LEDs burned out I fond a source for them and replaced same all worked fine.  After reassembling the unit I discovered in final test that the controlling chip went bad.  I think the chip is a EEPROM at least the package is a DIP-8.  The device has a function select push button and there are 4 flashing formats; wig-wag, flash twice wig-wag, all steady on; all on flash.  Any suggestions? 

Posted by Foxtrot70 7 years ago

Please use better SUBJECT lines

It would be REALLY NICE if when people posted a question in the forums, they put some useful information in the subject line so that people who might answer the question would have a quick clue as to whether they can help. Here are some particularly bad recent examples:Please tell me if this will workI need some help on a project.I need some helpQuestion?And to be fair, here are some subject lines that were OK to excellent (I was only interested in half, but at least I could tell from the other subject lines that I wasn't interested!):Help programming a 8 pin eepromAirsoftJoule Thief Troublesyour favorite song?

Posted by westfw 10 years ago

Gadget Gangster Propeller Platform

The Propeller Platform Module (pictured below) includes an 80Mhz, 160 MIPS Parallax Propeller microcontroller, 32kb of EEPROM with space for a second EEPROM, 5V and 3.3V Voltage Regulators and the pin sockets to add additional Gadget Gangster Platform modules like the LCD UI Module or the Prototyper Module.All Gadget Gangster Platform Modules utilize .1" pin spacing and are breadboard compatible. Here's a little video demonstration of the LCD UI and Propeller Modules: What is the Gadget Gangster Platform?The Gadget Gangster Platform is a lot like the Arduino with a few improvements on the basic idea;-Modules (a.k.a. shields) can be connected to each other on top and bottom. For example, you might have a Propeller module in the middle, an LCD UI on the top, and a prototyper on the bottom. We've got a few initial modules to start, and we'll continue to expand on the selection with more modules and microcontrollers.-Pin spacing is .1". This makes the Platform compatible with breadboards, and it lets you use Platform modules in combination with other project boards.-The board footprint is 3.8" x 2.5", which is the same footprint as ExpressPCB's MiniBoard service. This makes it easier to add your own custom module.-Because they're featured in Jon Williams' Spin Zone column in Nuts and Volts, they're well documented. The Propeller Platform Module will be the basis for many of projects described in his upcoming columns and the LCD UI module will featured in his September '09 column. -Platform Modules are licensed under the MIT license (essentially public domain), giving you the flexibility to use the design in commercial products or anything else without restriction.[/list]I'm super-excited about these new project boards. There's more info on Gadget Gangster but if you have any questions, you can just reply to this thread.

Posted by Gadget Gangster 9 years ago

What to do with old robot? / Cybot

I found an old robot that was part of one of those 'build it yourself' magazine series. I was gonna eBay it but found there was actually quite alot of cool stuff in there so I've compiled a list and I'm gonna make an instructable using some of the parts, But I need ideas / help.Here are (the best) parts.2x sets of ultrasonic emitters / receivers2x LDRs large2x smaller photoresistors (used for line following)2x set of inrfa red emitter& reciever leds2x bright white leds + various others2x 9v motors & gear housingsLCD display 5cm squreeepromspeed controllers selector switches etcand a load of pre programmed processors that can't be reused.some more technical details here

Posted by madmanmoe64 10 years ago

Attempting to create tiny, wearable, covert, simple button click counter for behavioral mod

Hi all, I've been searching both this forum and the internet in general and strangely have not come across what I'm looking to do even though to me it seems very simple. Here are the specifications/requirements of the device that I am trying to create: -extremely tiny form factor (ideally a ring sized device but I'll settle for a thin bracelet) -unobtrusive/inconspicuous (I guess a thin bracelet that could hide under a sleeve might be best) -battery powered/untethered (This is essential. The device would be useless if depended on a connection to a computer or wall socket) -battery life must last a full day -data logged is just a simple time/day stamp that would indicate when a button was clicked by the wearer      (wearer would manually click the button during the day when certain thoughts came up for him/her)       This requirement indicates that the micro controller chosen would need a clock built in and        some kind of storage - be able to upload the data to a computer I did my preliminary research considering these requirements and I came up with the following electronic components that might work: - teensy 3 (has real time clock and 2K EEPROM which should be plenty of memory for storing date stamps) - ulog (1MB of usable space across 3 analog channels, couldn't find anything about a built in clock) - Pro Micro - 3.3V/8MHz (not sure about built in real clock  but storage is 32K flash space) - OpenLog (wasn't clear about how much built in storage and didn't see any build in real time clock) These are the best I could find. If anyone has better suggestions please let me know? My idea is to connect a Mini Push Button Switch to one of the digital inputs on one these micro controllers/data loggers and write a simple sketch that records the time the button was pushed in a MMDDYYhhmm format (10 bytes per click). To power any of these micro controllers/data loggers I was planning to use a Coin Cell Battery - 12mm. I was going to sew the micro controllers/data loggers on one side of a thin piece of material that would serve as a bracelet and sew the battery on the other side. Although I'm not sure how to fix the battery to the cloth and how to connect it to the micro controllers/data loggers. I'm guessing I could find some kind of battery holder for the 12mm cell battery? Other Questions about my assumptions: Will I have enough storage left over on the flash space or EEPROM to store the data click after the sketch code has been loaded in? Will a watch battery provide enough energy to run this device all day? Is the Coin Cell Battery - 12mm the correct external power source for this project? I encourage any feed back, criticism, comments, help of any kind to move me along with this preparation so that I can move forward and purchase the parts I need. Thanks! Michael

Posted by mhussar 5 years ago

24 x 24 LED Matrix Project

I would like to share with you all an awesome project and some doubts and questions related to the same. This is a 24 x 24 LED Matrix project taken from here. All the data is taken from the same link. 24×24 LED dot matrix -->   This is pretty old circuit but I found it interesting to describe here. 24×24 LED display is formed by using 9 8×8 Dot LED matrix displays, that are connected to AT90S2313 MCU. MCU scans an indicator lines in series. Special PC program is written which allows drawing images on screen and transfer them via COM port to device. You can send images in series what gives an animation effect.   Circuit is was built using obsolete AT90S2313 MCU which can be replaced by Attiny2313 MCU with minor modifications of firmware. To make program work you event don’t need to connect device to computer COM port. You can store images in other master MCU EEPROM memory Each received byte from UART is immediately sent to 8 LEDs, second byte to next 8 LEDs and so on. Bytes has to be sent one by one without delay. USART is working at 115200 baud, 8bits, no parity. ---------------------------------------------------------------------------------------------------------------------------------- THE PROBLEMS >1>I really dont know if the circuit is good or not tell me if it is going to work. >2>I cant get 8x8 dot matrix displays so i am going to normal leds to a 24x24 one. >3>I have never worked with bus before (the bold red lines in the circuit) so i dont know how to connect it. >4>The schems are segmented i am finding it hard to figure out how to connect some of the segments. >5>Also i need to know how to hook it up to my pc. >6>I have never done programming so i need to know how to program the ic. THANK YOU I couldnt get the images uploaded nicely so i linked them. 1 2  

Posted by science_freak 8 years ago