This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* new_lcd_hardware.c | |
* | |
* Created: 2/8/2016 2:43:34 PM | |
* Author: keshab | |
*/ | |
#ifndef F_CPU | |
# define F_CPU 1000000UL | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* new_lcd_hardware.c | |
* | |
* Created: 2/8/2016 2:43:34 PM | |
* Author: keshab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define F_CPU 1000000UL | |
#include<avr/io.h> | |
#include<util/delay.h> | |
#include<inttypes.h> | |
#define rs PA0 | |
#define rw PA1 | |
#define en PA2 | |
void lcd_init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef F_CPU | |
# define F_CPU 1000000UL | |
#endif | |
#include<avr/io.h> | |
#include<util/delay.h> | |
void digital_value(int); | |
void ADC_initialization(void); | |
unsigned int ADC_read(unsigned int ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ADC_initialization(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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int ADC_read(unsigned int x) | |
{ | |
ADMUX|=x; //selecting cannel | |
ADCSRA|=(1<<ADSC); // start conversion | |
while(!(ADCSRA & (1<<ADIF))); // waiting for ADIF, conversion complete | |
ADCSRA|=(1<<ADIF); // clearing of ADIF, it is done by writing 1 to it | |
return (ADC); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void digital_value(int value) | |
{ | |
if(value==0) | |
{ | |
PORTC=0x00; | |
} | |
if ((value>0) & (value < 100)) | |
{ | |
PORTC=0x01; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int time = 500; | |
void setup() { | |
pinMode(0, OUTPUT); | |
pinMode(1, OUTPUT); | |
pinMode(2, OUTPUT); | |
pinMode(3, OUTPUT); | |
pinMode(4, OUTPUT); | |
pinMode(5, OUTPUT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int time = 500; // The higher the number, the slower the timing. | |
int ledPins[] = { 0,1,2,3,4,5,6,7 }; // an array of pin numbers to which LEDs are attached | |
int pinCount = 8; // the number of pins (i.e. the length of the array) | |
void setup() { | |
// the array elements are numbered from 0 to (pinCount - 1). | |
// use a for loop to initialize each pin as an output: | |
for (int thisPin = 0; thisPin < pinCount; thisPin++) { | |
pinMode(ledPins[thisPin], OUTPUT); |