Notes
Notes - notes.io |
float voltageValue=0;
float temperatura=0;
void setup()
{
DDRD=0xF0;
DDRB=0x03;
DDRC=B000000;
command(0x28);
delay(500);
command(0x0E);
delay(500);
command(0x01);
delay(500);
command(0x06);
init_CAN();
command(0x80);
}
void command(char LcdCommand)
// Basic function used in giving command
{
// to LCD
int en = 1;
int rs = 0;
char UpperHalf, LowerHalf;
UpperHalf = LcdCommand & 0xF0;
// upper 4 bits of command
PORTD &= 0x0F;
// flushes upper half of PortD to 0, but retains lower half of PortD
PORTD |= UpperHalf;
PORTB &= ~(1<<rs);
PORTB |= (1<<en);
_delay_ms(10);
PORTB &= ~(1<<en);
_delay_ms(10);
LowerHalf = ((LcdCommand<<4) & 0xF0); //lower 4 bits of command
PORTD &= 0x0F; // flushes upper half of PortD to 0, but retains lower half of PortD
PORTD |= LowerHalf;
PORTB &= ~(1<<rs);
PORTB |= (1<<en);
_delay_ms(10);
PORTB &= ~(1<<en);
_delay_ms(10);
}
void data(char AsciiChar)
// Basic function used in giving data
{ // to LCD
int en =1;
int rs = 0;
char UpperHalf, LowerHalf;
UpperHalf = AsciiChar & 0xF0;
// upper 4 bits of data
PORTD &= 0x0F;
// flushes upper half of PortD to 0, but retains lower half of PortD
PORTD |= UpperHalf;
PORTB |= (1<<rs);
PORTB |= (1<<en);
_delay_ms(10);
PORTB &= ~(1<<en);
_delay_us(400);
LowerHalf = ((AsciiChar<<4) & 0xF0); //lower 4 bits of data
PORTD &= 0x0F; // flushes upper half of PortD to 0, but retains lower half of PortD
PORTD |= LowerHalf;
PORTB |= (1<<rs);
PORTB |= (1<<en);
_delay_ms(10);
PORTB &= ~(1<<en);
_delay_us(400); }
void init_CAN(void){
ADCSRA=B11000111;
}
uint16_t read_CAN (uint8_t intrare )
{
ADMUX=
ADCSRA=ADCSRA|0x40;
while(ADCSRA&0x40){};
return ADC;
}
void afisare(float voltageValue){
int voltage,i,v[4]={0};
command(0xc8);
data('v');delay(150);
data('=');delay(200);
voltage=voltageValue;
while(voltage!=0){
v[i]=voltage%10;
voltage=voltage/10;
i++;
}
for(i=3;i<=0;i--){
data(v[i]);
delay(199);
}
}
float senzorValue;
void loop()
{
senzorValue=afisare
command(0x80);
scriere(VAR1);
delay(1000);
command(0xc0);
data('hh');
delay(1000);
command(0x01);
}
*/
char rs=0;
char en=1;
int sensor_val=0;
long int voltage_val=0,media;
int temp_val=0;
int ogl_temp;
int ogl_sensor;
long int ogl_voltage;
bool last_digit0;
void command(char lcdCmd);
void data(char ascii);
void init_display();
void init_CAN();
void setup()
{
Serial.begin(9600);
DDRD=0xF0;
DDRB=0x03;
delay(50);
init_display();
init_CAN();
}
void command(char lcdCmd) // Basic function used in giving command
{ // to LCD
char UpperHalf, LowerHalf;
UpperHalf = lcdCmd & 0xF0; // upper 4 bits of command
PORTD &= 0x0F; // flushes upper half of PortD to 0, but retains lower half of PortD
PORTD |= UpperHalf;
PORTB &= ~(1<<rs);
PORTB |= (1<<en);
delay(10);
PORTB &= ~(1<<en);
delay(10);
LowerHalf = ((lcdCmd<<4) & 0xF0); //lower 4 bits of command
PORTD &= 0x0F; // flushes upper half of PortD to 0, but retains lower half of PortD
PORTD |= LowerHalf;
PORTB &= ~(1<<rs);
PORTB |= (1<<en);
delay(10);
PORTB &= ~(1<<en);
delay(10);
}
void data(char AsciiChar) // Basic function used in giving data
{ // to LCD
char UpperHalf, LowerHalf;
UpperHalf = AsciiChar & 0xF0; // upper 4 bits of data
PORTD &= 0x0F; // flushes upper half of PortD to 0, but retains lower half of PortD
PORTD |= UpperHalf;
PORTB |= (1<<rs);
PORTB |= (1<<en);
delay(10);
PORTB &= ~(1<<en);
_delay_us(400);
LowerHalf = ((AsciiChar<<4) & 0xF0); //lower 4 bits of data
PORTD &= 0x0F; // flushes upper half of PortD to 0, but retains lower half of PortD
PORTD |= LowerHalf;
PORTB |= (1<<rs);
PORTB |= (1<<en);
delay(10);
PORTB &= ~(1<<en);
_delay_us(400);
}
void init_CAN(){
//ADSCRA=0xC7;
}
void init_display(){
command(0x0E);
delay(50);
command(0x2C);
delay(50);
command(0x01);
delay(50);
}
void loop()
{
//command(0x80);
//delay(1000);
//command(0xC6);
//delay(1000);
//command(0x0F);
//delay(1000);
//command(0x01);
//delay(1000);
//data(0x33);
//delay(1000);
media=0;
for(int i=0;i<10;i++){
sensor_val=analogRead(A0);
voltage_val= sensor_val * (5000.0 / 1023.0);
media+=voltage_val;
}
voltage_val=media/10.0;
Serial.print("Nr cuante=");
Serial.print(sensor_val);
Serial.print("n");
Serial.print("Tensiunea=");
Serial.print(voltage_val);
Serial.print(" mV");
Serial.print("n");
temp_val=0.1*voltage_val;
Serial.print("Temperatura=");
Serial.print(temp_val);
Serial.print(" C");
Serial.print("n");
command(0x01);
delay(50);
data('T');
data('E');
data('M');
data('P');
data('=');
ogl_temp=0;
if(temp_val%10==0){
last_digit0=true;
}
else{
last_digit0=false;
}
while(temp_val){
ogl_temp=ogl_temp*10+temp_val%10;
temp_val/=10;
}
while(ogl_temp){
data(ogl_temp%10+48);
ogl_temp/=10;
if(last_digit0){
data(48);
}
}
data(96);
//data(248);
data('C');
delay(1000);
command(0xC0);
delay(50);
data('N');
data('=');
ogl_sensor=0;
if(sensor_val%10==0){
last_digit0=true;
}
else{
last_digit0=false;
}
while(sensor_val){
ogl_sensor=ogl_sensor*10+sensor_val%10;
sensor_val/=10;
}
while(ogl_sensor){
data(ogl_sensor%10+48);
ogl_sensor/=10;
if(last_digit0){
data(48);
}
}
delay(1000);
command(0xC8);
delay(50);
data('U');
data('=');
ogl_voltage=0;
if(voltage_val%10==0){
last_digit0=true;
}
else{
last_digit0=false;
}
while(voltage_val){
ogl_voltage=ogl_voltage*10+voltage_val%10;
voltage_val/=10;
}
while(ogl_voltage){
data(ogl_voltage%10+48);
ogl_voltage/=10;
if(last_digit0)
data(48);
}
data('m');
data('V');
delay(1000);
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team