Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

c code with at commands to send value of sensor !!

Status
Not open for further replies.

lonely151

Newbie level 2
Joined
Oct 31, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
oman
Activity points
1,290
I have finsh this code for read from temp sensor then convert to digital
then send it to pc
and it work
Code:
#define F_CPU 3686400UL
#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include "uart.h"
#define sbi(port, bit) (port) |= (1 << (bit))

#define  loop_until_bit_is_clear(sfr, bit)   do { } while (bit_is_set(sfr, bit)) 

FILE uart_str = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW);



////////////////////////////////////////////////
void my_delay(int w) //Define delay function.
{
int i;
for(i=0; i<= w ; i++)
_delay_ms(1);
}




////////////////////////////////////////////////

void initUART()
{
	UBRRH =0;
	UBRRL = 11;	   // for baud rate=19200
	UCSRC = 0x86;	  // mode 8N1
	UCSRB = 0x18;	 // enable RX and TX
}
//---------------------------------------------------
void sendByte(char x)
{ 	while((UCSRA & 0x20)==0 )
	;	//wait till bit 5 of UCSRA is set check bit 5 (UDRE)
	UDR=x;
}

	
	//////////////////////////////////////
	
//stdout = stdin = &uart_str; // map stdin and stdout to serial port

int main(void)
{

ADMUX= 0b00100000; // chan 0, left adjusted,Vref=5
ADCSRA= 0b10000110; // ADC enabled, pre-scalar 64
DDRA= 0; //PORT A input



unsigned int x ,lsb , msb,c1,c2 ; //declare the temprature
char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8','9','A','B','C','D','E','F' };

unsigned int w;
unsigned int result;

////////////////////////////////////////////////
	ADMUX= 0b00100010; // chan 0, left adjusted,Vref=5
	ADCSRA = ADCSRA | 0x40 ; // start conversion.
		do {
		w = ADCSRA & 0x10;
		} while (w == 0); // repeat until EOC
	result = ADC; // the sampled data is in result
	// we can do whatever with the sampled data.
	//For now, we will display in on PORTD
	result = (result>>8); // truncate from 10 to
	x=result;
	/////////////////////////////////////////////


lsb = x& 0xf ;
msb = (x>>4) & 0xf ;
c1= hex[lsb];
c2= hex[msb];
while (1)
{

initUART();

{

        
sendByte('X');sendByte('=');sendByte(' ');
	                sendByte(c1);
		sendByte(c2);
				my_delay(1000);

	            }

}

return 0;
}
i need try to send this value (x) by sms
what will be do ??
where i write at command ? can any one tell me
 

This page shows you what you have to do to send an SMS message**broken link removed**
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top