Hello all,
I am a begginer programmer and I have some request I need to full understand the following program line after line which
recognise the one wire ds18b29 sensor address and transfer the addres to pc - hyperterminal.
I write the comment where I understand the code but I need to understand each line.
And here big request could anybody help me with writing the comment for each line.
Thank`s in advance.
#include <OneWire.h> //include one wire library
OneWire ds(3); // Connect your 1-wire device to pin 3
void setup(void) {
Serial.begin(9600); //start transmision with 9600 baundrate
discoverOneWireDevices();
}
void discoverOneWireDevices(void) {
byte i;
byte present = 0;
byte data[12];
byte addr[8];
Serial.print("Looking for 1-Wire devices...\n\r"); // write on the hyperterminal "Looking for 1-Wire devices... worlds
while(ds.search(addr)) {
Serial.print("\n\rFound \'1-Wire\' device with address:\n\r"); //write on the hyperterminal "Found \'1-Wire\' device with address:" worlds
for( i = 0; i < 8; i++) {
Serial.print("0x");
if (addr[i] < 16) {
Serial.print('0');
}
Serial.print(addr[i], HEX);
if (i < 7) {
Serial.print(", ");
}
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.print("CRC is not valid!\n");
return;
}
}
Serial.print("\n\r\n\rThat's it.\r\n");
ds.reset_search();
return;
}