Sign In

Controlling Printing Of Adc Values From Ldr In Serial Monitor Using Keys In Keyboard.

Aravind Manimaran India

Hardware: Atmega328p Running With 16hz Clock Wired To A Bread Board Software: Avr Coding In Arduino IDE

Im not able to write a code which prints the ADC values from ldr in the serial monitor of the arduino.The printing has to start when I press "s" and should stop when i press "e"



R Avinash
2016-07-02 13:41:22
So you have not written any code yet and want total code to be written by someone else? Right?
R Aravind Manimaran
2016-07-02 16:06:48
no i have tried writing the code.If you want the proof i can send the codes i have tried.the thing is im lacking time,as this is an assignment in my college.
R Avinash Gupta
2016-07-03 03:34:03
You have said you are using atmega328 on breadboard. So does that mcu has arduino bootloader programmed?

How you are programming it? Are you using usb to serial adapter?
R Aravind Manimaran
2016-07-03 07:04:25
yes,.....the arduino uno has a usb cable adapter that connects the mcu to my laptop
R Avinash Gupta
2016-07-04 06:32:01
Here is the code ... try it ...

void setup() { 
 //Initialize serial and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only

// first visible ASCIIcharacter '!' is number 33:
int thisByte = 33; 
// you can also write ASCII characters in single quotes.
// for example. '!' is the same as 33, so you could also use this:
//int thisByte = '!';  

void loop() { 
  Serial.println("Press 's' to start and 'e' to stop data acquisition"); 
  //wait until a character arrives
  //One character arrived read it
  if(ch != 's' && ch !='S') return;
  //We have received start command (s) so start sending data
  while(ch!='e' && ch!='E')
    unsigned int ldr = analogRead(0);
    char msg[10];
    sprintf(msg,"LDR: %d", ldr);
R Avinash Gupta
2016-07-05 02:23:09
We are waiting for your response ....

Post a reply to Aravind Manimaran

Think you can help Aravind Manimaran ? Then post your thoughts that might help Aravind Manimaran. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.