Skip to content

Instantly share code, notes, and snippets.

View prasant1010's full-sized avatar

Prasant prasant1010

View GitHub Profile
#ifndef ButtonPress
#define ButtonPress
#include <avr/io.h>
char ButtonPressed(int buttonNumber, unsigned char pinOfButton, int portBit, int confidenceLevel);
char Pressed[numberOfButtons];
int Pressed_Confidence_Level[numberOfButtons]; //Measure button press cofidence
int Released_Confidence_Level[numberOfButtons]; //Measure button release confidence
char ButtonPressed(int buttonNumber, unsigned char pinOfButton,int portBit, int confidenceLevel)
{
/*
* new_lcd_hardware.c
*
* Created: 2/8/2016 2:43:34 PM
* Author: keshab
*/
#ifndef F_CPU
# define F_CPU 1000000UL
#endif
/*
* new_lcd_hardware.c
*
* Created: 2/8/2016 2:43:34 PM
*  Author: keshab
#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();
#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 );
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
}
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);
}
void digital_value(int value)
{
if(value==0)
{
PORTC=0x00;
}
if ((value>0) & (value < 100))
{
PORTC=0x01;
}
int time = 500;
void setup() {
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
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);