Weather
Weather
The basic requirement for designing a power supply is as follows, 1.The voltage levels required for operating the devices is +5volt. Here +5Volt required for operating microcontroller. And as well as required for drivers and amplifiers and ir transmitters and receivers. 2. The current requirement of each device or load must be added to estimate the final capacity of the power supply. The power supply always specified with one or multiple voltage outputs along with a current capacity. As it is estimate the requirement of power is approximately as follows, Out Put Voltage = +5Volt, Capacity = 1000mA The power supply is basically consisting of three sections as follows, 1. 2. 3. Step down section Rectifier Section Regulator section
Design principle: There are two methods for designing power supply, the average value method and peak value method. In case of small power supply peak value method is quit economical, for a particular value of DC output the in put AC requirement is appreciably less. In this method the DC out put is approximately equal to Vm. A full wave bridge rectifier is designed using two diodes and the output of the rectifier is filtered with a low pass filter. The capacitor value is decided so that it will back up for the voltage and current during the discharging period of the DC output. In this case the out put with reference to the center tap of the transformer is taken in to consideration, though the rectifier designed is a full wave bridge rectifier but the voltage across the load is a half wave rectified out put. The Regulator section used here is configured with a series regulator LM78XX the XX represents the output voltage and 78 series indicates the positive voltage regulator 79 series indicates the negative regulator for power supply. The positive regulator works satisfactorily between the voltage XX+2 to 40 Volt DC. The output remains constant within this range of voltage. The output remains constant within this range of voltage.
Circuit connection: - In this we are using Transformer (12-0-12) v / 1mA, IC 7805 , diodes IN 4007,LED & resistors. Here 230V, 50 Hz ac signal is given as input to the primary of the transformer and the secondary of the transformer is given to the bridge rectification diode. The positive out put
of the bridge rectifier is given as i/p to the IC regulator (7805) through capacitor (1000uf/25v). indicator. Circuit Explanations: - When ac signal is given to the primary of the transformer, due to the magnetic effect of the coil magnetic flux is induced in the coil (primary) and transfer to the secondary coil of the transformer due to the transformer action. Transformer is an electromechanical static device which transformer electrical energy from one coil to another without changing its frequency. Here the diodes are connected to the two +12volt output of the transformer. The secondary coil of the transformer is given to the diode circuit for rectification purposes. The o/p of the IC regulator is given to the LED through resistors to act as
During the +ve cycle of the ac signal the diodes D1 conduct due to the forward bias of the diodes and diodes D2 does not conduct due to the reversed bias of the diodes. Similarly during the ve cycle of the ac signal the diodes D2 conduct due to the forward bias of the diodes and the diodes D1 does not conduct due to reversed bias of the diodes. The output of the bridge rectifier is not a power dc along with rippled ac is also present. To overcome this effect, a low pass filter is connected to the o/p of the diodes (D1 & D2). Which removes the unwanted ac signal and thus a pure dc is obtained. Here we need a fixed voltage, thats for we are using IC regulators (7805 ).Voltage regulation is a circuit that supplies a constant voltage regardless of changes in load current. This ICs are designed as fixed voltage regulators and with adequate heat sinking can deliver output current in excess of 1A. The o/p the full wave rectifier is given as input to the IC regulator through low pass filter with respect to GND and thus a fixed o/p is obtained. The o/p of the IC regulator (7805) is given to the
LED for indication purpose through resistor. Due to the forward bias of the LED, the LED glows ON state, and the o/p are obtained from the pin no-3.
PB0-PB7
PD0-PD7
The microcontroller used here is atmega 16 which has inbuilt adc and counter along with microcontroller.the pin configuration and details are given below.
The ATmega16 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega16 achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumption versus processing speed. The AVR core combines a rich instruction set with 32 general purpose working registers.
All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers.
The ATmega16 provides the following features: 16K bytes of In-System Programmable Flash Program memory with Read-While-Write capabilities, 512 bytes EEPROM, 1K byte SRAM, 32 general purpose I/O lines, 32 general purpose working registers, a JTAG interface for Boundary-scan, On-chip Debugging support and programming, three flexible Timer/Counters with compare modes, Internal and External Interrupts, a serial programmable USART, a byte oriented Two-wire Serial Interface, an 8-channel, 10-bit ADC with optional differential input stage with programmable gain (TQFP package only),a programmable Watchdog Timer with Internal Oscillator, an SPI serial port, and six software selectable power saving modes. The Idle mode stops the CPU while allowing the USART, Two-wire interface, A/D Converter, SRAM, Timer/Counters, SPI port, and interrupt system to continue functioning. The Power-down mode saves the register contents but freezes the Oscillator, disabling all other chip functions until the next External Interrupt or Hardware Reset. In Power-save mode, the Asynchronous Timer continues to run, allowing the user to maintain a timer base while the rest of the device is sleeping.
The ADC Noise Reduction mode stops the CPU and all I/O modules except Asynchronous Timer and ADC, to minimize switching noise during ADC conversions. In Standby mode, the crystal/resonator Oscillator is running while the rest of the device is sleeping.
This allows very fast start-up combined with low-power consumption. In Extended Standby mode, both the main Oscillator and the Asynchronous Timer continue to run. The device is manufactured using Atmels high density nonvolatile memory technology. The On-chip ISP Flash allows the program memory to be reprogrammed in-system through an SPI serial interface, by a conventional nonvolatile memory programmer, or by an On-chip Boot program running on the AVR core. The boot program can use any interface to download the application program in the Application Flash memory. Software in the Boot Flash section will continue to run while the Application Flash section is updated, providing true Read-While-Write operation. By combining an 8-bit RISC CPU with In-System SelfProgrammable Flash on a monolithic chip, the Atmel ATmega16 is a powerful microcontroller that provides a highly-flexible and cost-effective solution to many embedded control applications. The ATmega16 AVR is supported with a full suite of program and system development tools including: C compilers, macro assemblers, program debugger/simulators, in-circuit emulators, and evaluation kits.
Pin Descriptions
VCC Digital supply voltage. GND Ground. Port A (PA7..PA0) Port A serves as the analog inputs to the A/D Converter. Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port pins can provide internal pull-up resistors (selected for each bit). The Port A output buffers have symmetrical drive characteristics with both high sink and source capability. When pins PA0 to PA7 are used as inputs and are externally pulled low, they will source current if the internal pull-up resistors are activated. The Port A pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port B (PB7..PB0) Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running.Port B also serves the functions of various special features of the ATmega16 . Port C (PC7..PC0) Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running. If the JTAG interface is enabled, the pull-up resistors on pins PC5(TDI), PC3(TMS) and PC2(TCK) will be activated even if a reset occurs.
Port C also serves the functions of the JTAG interface and other special features of the ATmega16 as listed on page 61. Port D (PD7..PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port D pins that are externally pulled low will
source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port D also serves the functions of various special features of the ATmega16. RESET Reset Input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running. The minimum pulse length is 0.1 vcc. Shorter pulses are not guaranteed to generate a reset. XTAL1 Input to the inverting Oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting Oscillator amplifier. AVCC AVCC is the supply voltage pin for Port A and the A/D Converter. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. AREF AREF is the analog reference pin for the A/D Converter.
Adc
10-bit Resolution 0.5 LSB Integral Non-linearity 2 LSB Absolute Accuracy 13 - 260 s Conversion Time Up to 15 kSPS at Maximum Resolution 8 Multiplexed Single Ended Input Channels 7 Differential Input Channels 2 Differential Input Channels with Optional Gain of 10x and 200x(1) Optional Left adjustment for ADC Result Readout 0 - VCC ADC Input Voltage Range Selectable 2.56V ADC Reference Voltage Free Running or Single Conversion Mode ADC Start Conversion by Auto Triggering on Interrupt Sources Interrupt on ADC Conversion Complete Sleep Mode Noise Canceler ATmega16 has an inbuilt 10 bit, 8-channel ADC system. Some of the basic features of Armega16 ADC are:
8 Channels.
10-bit Resolution. Input voltage range of 0 to Vcc. Selectable 2.56V of internal Reference voltage source. AREF pin for External Reference voltage. ADC Conversion Complete Interrupt.
ADC channels in Atmega16 are multiplexed with PORTA and use the common pins (pin33 to pin40) with PORTA. ADC system of Atmega16 microcontroller consists of following pins: i. ii. ADC0-ADC7: 8 Channels from Pin 40 to Pin 33 of Atmega16 ADC peripheral. AREF: Pin32 of Atmega16 microcontroller, the voltage on AREF pin acts as the reference
voltage for ADC conversion, reference voltage is always less than or equal to the supply voltage, i.e., Vcc. iii. AVCC: Pin30, this pin is the supply voltage pin for using PORTA and the ADC; AVCC pin
must be connected to Vcc (microcontroller supply voltage) to use PORTA and ADC.
Note: External reference voltage source can be used at AREF pin. However, Atmega16 also has internal reference voltage options of 2.56V and Vref = Vcc.
The figure below shows the pin configuration for ADC system of Atmega16 microcontroller.
ADC Registers
To use the ADC peripheral of Atmega16, certain registers need to be configured. i. ADMUX (ADC Multiplexer And Selection Register)
REFS[0:1] bits determine the source of reference voltage whether it is internal or the external voltage source connected to AREF pin. MUX[4:0] bits are used to select between the channels which will provide data to ADC for conversion. ADLAR bit when set to 1 gives the left adjusted result in data registers ADCH and ADCL.
ii.
ADEN: ADC Enable bit, this bit must be set to 1 for turning ADC on. ADSC: ADC Start Conversion bit, this bit is set to 1 to start ADC conversion, as soon as conversion is completed this bit is set back to 0 by the hardware. ADATE: ADC Auto Trigger Enable, this bit is set to 1 to enable auto triggering of ADC conversion.
ADIF: ADC Interrupt Flag, this bit is set to 1 when ADC conversion gets complete. ADIE: ADC Interrupt Enable, this bit is set to 1 if we want to activate the ADC conversion complete interrupt. ADPS[0:2]: ADC Prescaler bits, these bits are used to set the ADC clock frequency, the configuration of these bits determine the division factor by which the microcontroller clock frequency is divided to get the ADC clock frequency. The figure above shows the prescaler bit values for respective division factor.
The ADC clock frequency must lie somewhere between 50 KHz to 200 KHz.
iii.
When the ADC conversion is complete the data is stored in these two registers. The data configuration depends on the ADLAR bit value of ADMUX register. If ADLAR=0, data is right adjusted and if ADLAR=1, data is left adjusted. Always read ADCL first and then ADCH. In cases where the 8-bit precision is enough set the ADLAR bit to 1 to left adjust the data and read only the ADCH data register. When ADLAR = 0,
When ADLAR = 1,
Circuit description
Connect the circuit as shown in the circuit diagram. A ceramic capacitor 104 is connected in between AVcc (pin 30) and Aref (pin 32). AVcc (pin 30) is connected to external supply +5V. Code explanation To interface analog device with AVR microcontroller, follow the following steps for programming it. Step1: To initialize ADC i. ii. iii. Set the value in ADMUX register according to the ADC channel and the reference voltage. Set the Prescaler bits accordingly in ADCSRA register. Set the ADEN bit to enable the ADC.
void ADC_init(void) // Initialization of ADC { ADMUX=(1<<REFS0); // AVcc with external capacitor at AREF ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); // Enable ADC and set Prescaler division factor as 128 }
Step2: To read the analog value i. ii. iii. iv. v. Put the channel value in ADMUX Start the conversion by setting the ADSC bit. Monitor the ADIF bit for conversion complete. Clear
unsigned int ADC_read(unsigned char ch) { ch= ch & 0b00000111; ADMUX |= ch; ADCSRA|=(1<<ADSC); while(!(ADCSRA & (1<<ADIF))); ADCSRA|=(1<<ADIF); writing 1 to it return (ADC); }
// channel must be b/w 0 to 7 // selecting channel // start conversion // waiting for ADIF, conversion complete // clearing of ADIF, it is done by
LCD display:
The display used here is 16x2 LCD (Liquid Crystal Display); this means 16 characters per line by 2 lines. A very popular standard exists which allows us to communicate with the vast majority of LCDs regardless of their manufacturer. The standard is referred to as HD44780U, which refers to the controller chip which receives data from an external source (in this case, the Atmega16) and communicates directly with the LCD. The 44780 standard requires 3 control lines as well as 8 I/O lines for the data bus
The three control lines are referred to as EN, RS, and RW. The EN line is called "Enable." This control line is used to tell the LCD that we are sending it data. To send data to the LCD, our program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again. The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is text data which should be displayed on the screen. For example, to display the letter "T" on the screen you would set RS high. The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands--so RW will almost always be low. In our case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.
The above figure shows 16*2 LCD Display. The figure below is to show the pin diagram of before mentioned LCD.
LCD Circuit:
Testing (D.C. Conditions): -> PIN 7 to 14 are data pins. -> Voltage at pin 2 is +5.00V -> Pin 3 is connected to 10K variable resistance for contrast setting. -> Pin 4, 5, 6 are control lines connected to PORT D.
Programming Steps Sequence: 1) Initialize the LCD. 2) Select the command or instruction register (RS=0 or RS=1). 3) Set RW low (to write to LCD). 4) Send a high to low pulse on EN pin. 5) Move to instruction or command function. 6) Repeat above steps.
STEP 1 : Identify : Determine what you want LCD are available in many flavors which are specified as follows 16x1 , 16x2 , 20x2 in the format AxB where A is the number of columns ( chatters ) and B is the number of Rows ( lines ) An LCD might also be Back lit . STEP 2 : Connect : most of the LCD's follow the standard Hitachi Pin out which is simply ...
Parame ter
R S
R / W
D B 7
D B 6
D B 5
D B 4
D B 3
D B 2
D B 1
D B 0
Note
Clear Display
1.64m s 40us1.64m s DB1=1:Incre ment DB1=0:Decr ement DB0=1:The display is shifted DB0=0:The display is not shifted 40 s DB2=1:Displ ay on DB2=0: Display off DB1=1:Curs or on DB1=0: Cursor off DB0=1:Blinki ng on DB0=0:Blinki ng off DB3=1:Shift s display one character DB2=1:Right shift DB2=0:Left shift DB4=1:8 bits DB4=0:4 bits DB3=1:2
Return Home
1 / D
40us1.64m s
40us
S C
R L
40us
Functio n Set
D L
40us
lines display (1/16 duty) DB3=0:1 line display DB2=1:5 10 dots , 1/11 duty DB2=1:5 7 dots , 1/8 duty CRA Address Corresponds to the cursor address
C R A
C R A
C R A
C R A
C R A
C R A
40us
D D A
D D A
D D A
D D A
D D A
D D A
40us
B F
D C A
D C A
D C A
D C A
D C A
D C A
D C A
1us
W D
W D
W D
W D
W D
W D
W D
W D
Write Data
40us
R D
R D
R D
R D
R D
R D
R D
R D
Read Data
40us
* : Does Not Matter DDRAM : Display Data RAM CGRAM : Character Generator RAM Address : These are where the characters are meant to be displayed before sending data into the LCD the address can be specified if you want the string to be printed somewhere in the middle after that the address simply increase each time a new character is passed . A simple 16x1 might be something like this 16x1
0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
4 0
4 1
4 2
4 3
4 4
4 5
4 6
4 7
16x2 0 0 4 0 0 1 4 1 0 2 4 2 0 3 4 3 0 4 4 4 0 5 4 5 0 6 4 6 0 7 4 7 0 8 4 8 0 9 4 9 0 A 4 A 0 B 4 B 0 C 4 C 0 D 4 D 0 F 4 F 0 E 4 E
After Connecting the LCD to the Micro controller And Apply Power The LCD will just show some squares on the screen which might not even cover the whole screen . Adjust the contrast till these squares are barely visible . For saving Pins on the micro controller i have simply put the RW line connected to the ground (and used a small delay instead of checking the line for the busy flag for the writing )
in hermetic TO-46 transistor packages, while the LM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor package. The LM35D is also available in an 8-lead surface mount small outline package and a plastic TO-220 package.
Features
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. Calibrated directly in Celsius (Centigrade) Linear + 10.0 mV/C scale factor 0.5C accuracy guaranteeable (at +25C) Rated for full 55 to +150C range Suitable for remote applications Low cost due to wafer-level trimming Operates from 4 to 30 volts Less than 60 A current drain Low self-heating, 0.08C in still air Nonlinearity only 14C typical Low impedance output, 0.1 for 1 mA load
CODE- TEMPERATURE
#include <avr/io.h> #include <util/delay.h> #include<compat/deprecated.h> #define rs PC0 #define en PC1 #define dataport PORTB void LCD_init(void); void wrcomm (unsigned char CMD); void wrdata (unsigned char Data); void LCD_DisplayString(const unsigned char *string);
void LCD_init(void) { wrcomm(0x38); //initialize LCD 2 lines, 5x7 matrix wrcomm(0x06);//Clear LCD wrcomm(0x0C); //Display on Cursor Blinking wrcomm(0x01);//Cursor at line 1, position 1 wrcomm(0x80); //Shift Entire Display To Right
void wrcomm(unsigned char Command) { cbi(PORTC,rs) ; dataport = Command; sbi(PORTC,en); _delay_ms(1); cbi(PORTC,en); _delay_ms(10); } void wrdata(unsigned char Data) { sbi(PORTC,rs) ; dataport= Data; sbi(PORTC,en);
_delay_ms(1); cbi(PORTC,en); _delay_ms(10); } void LCD_DisplayString (const unsigned char *string) { //LCD_Cursor (row, column); while (*string) wrdata(*string++); }
void adc_init() { ADCSRA=0XE5; } unsigned char adc_channel_init(unsigned char x) { unsigned char x1=0; ADMUX=0X60 | x; _delay_ms(10); x1=ADCH; return x1; } void main() { DDRA=0x00; DDRC = 0xff; DDRB=0XFF; adc_init(); LCD_init(); unsigned char x=0,y=0,z=0, counter=0,counter0=0,counter1=0,start=0,a=0,b=0,c=0; wrcomm(0x01); wrcomm(0x80); LCD_DisplayString("*** WELCOME *** ");
CODE: HUMIDITY
#define rs PC0 #define en PC1 #define dataport PORTB void LCD_init(void); void wrcomm (unsigned char CMD); void wrdata (unsigned char Data); void LCD_DisplayString(const unsigned char *string);
wrcomm(0x06);//Clear LCD
void wrcomm(unsigned char Command) { cbi(PORTC,rs) ; dataport = Command; sbi(PORTC,en); _delay_ms(1); cbi(PORTC,en); _delay_ms(10); }
void LCD_DisplayString (const unsigned char *string) { //LCD_Cursor (row, column); while (*string) wrdata(*string++); }
DDRB=0XFF; adc_init(); LCD_init(); unsigned char x=0,y=0,z=0,a=0,b=0,l=0,m,n,p, counter=0,counter0=0,counter1=0,start=0,s=0; wrcomm(0x01); wrcomm(0x80); LCD_DisplayString(" WELCOME ");
while(1) {
s=adc_channel_init(0);
a=(4000/130)*s;
{ l=60;
{ l=10;
} }
CO2 sensor
CO2
Code:
#define rs PC0 #define en PC1 #define dataport PORTB void LCD_init(void); void wrcomm (unsigned char CMD); void wrdata (unsigned char Data); void LCD_DisplayString(const unsigned char *string);
wrcomm(0x06);//Clear LCD
void wrcomm(unsigned char Command) { cbi(PORTC,rs) ; dataport = Command; sbi(PORTC,en); _delay_ms(1); cbi(PORTC,en); _delay_ms(10); }
void wrdata(unsigned char Data) { sbi(PORTC,rs) ; dataport= Data; sbi(PORTC,en); _delay_ms(1); cbi(PORTC,en);
_delay_ms(10); }
void LCD_DisplayString (const unsigned char *string) { //LCD_Cursor (row, column); while (*string) wrdata(*string++); }
unsigned char adc_channel_init(unsigned char x) { unsigned char x1=0; ADMUX=0X60 | x; _delay_ms(10); x1=ADCH; return x1; }
DDRB=0XFF; adc_init(); LCD_init(); unsigned char x=0,y=0,z=0,a=0,b=0,l=0,m,n,p, counter=0,counter0=0,counter1=0,start=0,s=0; wrcomm(0x01); wrcomm(0x80); LCD_DisplayString("*** WELCOME *** ");
while(1) {
s=adc_channel_init(0);
a=(4000/130)*s;
wrdata(l+48);
_delay_ms(500);
} }
#define rs PC0 #define en PC1 #define dataport PORTB void LCD_init(void); void wrcomm (unsigned char CMD); void wrdata (unsigned char Data); void LCD_DisplayString(const unsigned char *string);
wrcomm(0x06);//Clear LCD
void wrcomm(unsigned char Command) { cbi(PORTC,rs) ; dataport = Command; sbi(PORTC,en); _delay_ms(1); cbi(PORTC,en); _delay_ms(10); }
void wrdata(unsigned char Data) { sbi(PORTC,rs) ; dataport= Data; sbi(PORTC,en); _delay_ms(1); cbi(PORTC,en); _delay_ms(10); }
void LCD_DisplayString (const unsigned char *string) { //LCD_Cursor (row, column); while (*string) wrdata(*string++); }
unsigned char adc_channel_init(unsigned char x) { unsigned char x1=0; ADMUX=0X60 | x; _delay_ms(10); x1=ADCH; return x1; }
void main() {
DDRB=0XFF; adc_init(); LCD_init(); unsigned char x=0,y=0,z=0,a=0,b=0,l=0,m,n,p, counter=0,counter0=0,counter1=0,start=0,s=0; wrcomm(0x01); wrcomm(0x80); LCD_DisplayString("*** WELCOME *** ");
while(1) {
s=adc_channel_init(0);
a=(4000/130)*s;
LCD_DisplayString("force =");
l=5;
l=0;
wrdata(l+48);
_delay_ms(500);
#define rs PC0 #define en PC1 #define dataport PORTB void LCD_init(void); void wrcomm (unsigned char CMD);
void wrdata (unsigned char Data); void LCD_DisplayString(const unsigned char *string);
wrcomm(0x06);//Clear LCD
void wrdata(unsigned char Data) { sbi(PORTC,rs) ; dataport= Data; sbi(PORTC,en); _delay_ms(1); cbi(PORTC,en); _delay_ms(10); }
void LCD_DisplayString (const unsigned char *string) { //LCD_Cursor (row, column); while (*string) wrdata(*string++); }
void adc_init()
{ ADCSRA=0XE5; }
unsigned char adc_channel_init(unsigned char x) { unsigned char x1=0; ADMUX=0X60 | x; _delay_ms(10); x1=ADCH; return x1; }
DDRB=0XFF; adc_init(); LCD_init(); unsigned char x=0,y=0,z=0,a=0,b=0,l=0,m,n,p, counter=0,counter0=0,counter1=0,start=0,s=0; wrcomm(0x01); wrcomm(0x80); LCD_DisplayString("*** WELCOME *** ");
while(1) {
s=adc_channel_init(0);
a=(4000/130)*s;
l=3;
wrdata(l+48);
wrdata('m');
_delay_ms(500);
} }