[SOLVED] CPE301 Lab # 08-ATmega Analog to Digital Converters by initializing

40.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

Rate this product

To learn how to program the ATmega Analog to Digital Converters by initializing and using the appropriate special function registers. You will develop two functions, adc_init, and adc_read, and a program which uses the two functions to read analog data from a photoresistor and sends the data over serial to a PC.

Procedure:

  1. Read chapter 8 of the textbook and browse section 26 of the Atmel 2560’s datasheet, paying extra attention to sections 26.2, 26.3, 26.4, and 26.8.
  2. Write two ANSI C functions:
    1. void adc_init( ) – Initializes the Analog to Digital Converter to be ready to read analog data.
    2. unsigned int adc_read(unsigned char adc_channel) – Returns the analog data read from the analog channel given as a parameter.
  3. Connect a photoresistor and an axial resistor in series as a voltage divider and write a program which reads the analog voltage of the divider and sends the voltage values over serial to your PC. Use the Arduino IDE’s Serial Plotter to plot the voltage values.
  4. Modify the program to turn on the on-board LED when the light level is above some threshold. Notes:

 

 

 

 

 

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.