Lab11
Additional header files into your Lab11 https://db.tt/2XuClltyg6
code
// Lab 11A
// ADC_LDR_Light_Sensor.ino
// read the LDR sensor on PC1(ADC1) and display on serial terminal
// connect LDR to PC1
#include <avr/io.h>
#include <util/delay.h>
#include "USART.h"
#include "ADC.h"
#include <stdio.h>
#include <string.h>
int main(void) {
char text[30];
// initialise UART
initUSART();
// initialise ADC, PC1
initADC(1);
// print some text
printString("LDR - Light sensor program\r\n");
printString("Getting sensor reading.\r\n");
// keep sending AIN1 value
while (1) {
int LDR_reading = getADCValue(1);
sprintf(text, "LDR = %d\r\n", LDR_reading);
printString(text);
_delay_ms(1000);
}
return 0;
}
Comments