POdarilo sa mi najst na internete tento jednoduchy program ale ako rozdelit prijem dat do dvoch okien?Na jednej vetvie mam 2 cidla ds18b20 Visual Basic 6
Private Sub Form_Load()
With MSComm1
If .PortOpen Then .PortOpen = False
.CommPort = 3
.Settings = "9600,N,8,1"
.DTREnable = True
.RTSEnable = True
.RThreshold = 1
.SThreshold = 0
.PortOpen = True
End With
With Text1
.BackColor = vbWhite
.Locked = True
.Text = ""
End With
End Sub
Private Sub MSComm1_OnComm()
Dim strInput As String
strInput = TextBox1.Text
With MSComm1
'test for incoming event
Select Case .CommEvent
Case comEvReceive
'display incoming event data to displaying textbox
strInput = .Input
Text1.SelText = strInput
End Select
End With
End Sub
Arduino
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = { 0x28, 0x6C, 0x2B, 0x24, 0x03, 0x00, 0x00, 0xB2 };
DeviceAddress outsideThermometer = { 0x28, 0x48, 0x24, 0x24, 0x03, 0x00, 0x00, 0xB7 };
void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(insideThermometer, 10);
sensors.setResolution(outsideThermometer, 10);
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("?");
} else {
Serial.print(tempC);
}
}
void loop(void)
{
delay(1000);
sensors.requestTemperatures();
printTemperature(insideThermometer);
Serial.print("\n\r");
printTemperature(outsideThermometer);
Serial.print("\n\r");
}
|