Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <Ethernet.h>
- #include <Udp.h>
- #include <EthernetUdp.h>
- // Communications
- EthernetUDP Udp; // To send & receive packets using UDP
- /**********************************************************
- CETS bir grup mac adresine statik IP atadı.
- Bu mac adreslerini kullanarak DHCP kullanırsanız,
- Statik IP atanır. Aksi takdirde,
- Kendi mac add ve IP adresini bir cihaza yüklemek zorunda kalırsa
- Airpenn net'in güvenlik sayfasına gidin.
- Bu mac ve statik adresler,
- Mühendislikbinası
- .***********************************************************/
- // MAC ve IP dizilimindeki "**" değerini atanmış rakamlarla değiştirin
- byte mac[] = {0x2A, 0x00, 0x00, 0x00, 0x00, 0x00};
- byte ip[] = {192, 168, 1, 50};
- byte remoteIp[4] = {192, 168, 1, 51}; // Receiver unit’s IP address
- // -------- Aşağıdaki bölümü değiştirmeyin -----------------
- char UDPMessageBuffer[80];
- const unsigned int localPort = 9631;
- unsigned int remotePort = 1369;
- // ----------------------------------------------------------
- // Sıcaklık sensorune bağlı pini yıldızların olduğu yere yazın
- int analogPin = 05;
- void setup()
- {
- Ethernet.begin(mac, ip); // Set up the Ethernet Shield
- Udp.begin(localPort); // Open a socket for this port
- Serial.begin(9600); // Set up serial monitor with PC
- }
- void loop()
- {
- /****************************************************
- Print out the values from the temperature sensor onto
- the serial monitor in degrees Fahrenheit. Math required
- to convert the value to temperature in F. You should
- have figured this out for your pre-lab.
- ****************************************************/
- float val = analogRead(analogPin);
- int degreeF = val -10 +10; // Replace *s with some math(+, -, *, /)
- Serial.println(degreeF); // Show value on serial monitor
- // Alıcı Arduino ya sıcaklık değerlerini gönder
- itoa(degreeF, UDPMessageBuffer, 10);
- Udp.sendPacket(UDPMessageBuffer, remoteIp, remotePort);
- strcpy(UDPMessageBuffer, ""); // Clear the message
- // Delay for 200ms so temperature is updated once every 200ms
- delay(200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement