How store the data into RAM with ID for each input?

11 Mar 2011

In this program I read the 6 analog inputs and send this data to urat for every 2 min. But I want to store this data into RAM with each ID for each input.After this only i want to send this through uart. How to frame this? could you help me?

  1. include <mbed.h> AnalogIn ain_UseA(p15); AnalogIn ain_UseB(p16); AnalogIn ain_UseC(p17); AnalogIn ain_UseD(p18); AnalogIn ain_UseE(p19); AnalogIn ain_UseF(p20); BusOut myled1(LED1); Ticker ADC; float vdiv = (3.3 / 65535); float avg[6] = {0,0,0,0,0,0}; void read_ADC();

Serial uart(p28, p27); int main() {

uart.baud(9600); uart.format(8,Serial::None,1); ADC.attach(&read_ADC, 20.0); float avg[6];

while( 1 ){ } } void read_ADC() { avg[0] = (avg[0]+(float)ain_UseA.read_u16()* vdiv)/2; avg[1] = (avg[1]+(float)ain_UseB.read_u16()* vdiv)/2; avg[2] = (avg[2]+(float)ain_UseC.read_u16()* vdiv)/2; avg[3] = (avg[3]+(float)ain_UseD.read_u16()* vdiv)/2; avg[4] = (avg[4]+(float)ain_UseE.read_u16()* vdiv)/2; avg[5] = (avg[5]+(float)ain_UseF.read_u16()* vdiv)/2; uart.printf("AI1:%5.3f\n AI2:%5.3f\n AI3:%5.3f\n AI4:%5.3f\n AI5:%5.3f\n AI6:%5.3f\r\n ", avg[0],avg[1],avg[2],avg[3],avg[4],avg[5]); }

11 Mar 2011

please use code tags,

makes reading your code more pleasant

11 Mar 2011

See http://mbed.org/forum/mbed/topic/1983/?page=1#comment-9964 where you seem to have posted this question previously already.