Re: Read/Write USB

new topic     » goto parent     » topic index » view thread      » older message » newer message

I did this a while ago to get info from a DS18B20 temp sensor connected to an Arduino

include serial.ew 
include std/get.e 
 
atom hCom 
sequence result 
integer VK_SPACE = #20 
integer state = 0 
atom t0 = time() 
 
public object temperature 
 
hCom = serial_open(10) 
 
if hCom != -1 then 
	while 1 do 
		if time() - t0 then 
			 
			temperature = value(serial_gets(hCom)) 
			temperature = temperature[2] 
			 
			 
			--printf(1,"%3.2fC,  %3.2fF\n",{temperature,temperature*9/5+32}) 
			if get_key() = VK_SPACE then 
				exit 
			end if 
			 
			t0 = time() 
		end if 
	end while 
else  
	puts(1,"No connection to Arduino\n\n") 
	puts(1,"Press Enter\n") 
	getc(0) 
end if 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu