Individual Assigment
* write an application that interfaces a user with an input and/or output device that you made
Group Assigment
* compare as many tool options as possible
#include "DHT.h" //Including the sensor library
#define DHT11_PIN 2 // defining the physical sensor - telling the board on which PIN the sensor data in supplied
DHT dht; // declaration needed for DHT library
void setup() //setup void in which we state things that we want to declare once for whole code operation like pins etc.
{
Serial.begin(9600); // declaration of badurate need to communicate with board on serial monitor
dht.setup(DHT11_PIN); // declaration of type of the sensor applied for library purpose
}
void loop() // loop void is a section that is repeated continuously
{
int temp = dht.getTemperature(); // using command supplied by library to read value of temperature and signing it into a int valuable
Serial.print(temp); //printing the value on serial monitor
Serial.println("*C"); // adding information about the value
delay(500); //delay between next readout
}
import processing.serial.*;
Serial port; // Create object from Serial class
float val; // Data received from the serial port
void setup() {
size(200, 200);
noStroke();
frameRate(10);
port = new Serial(this,"COM4", 9600);
}
void draw(){
if (port.available() > 0){
val = port.read();
fill(255);
rect(75, 25, 50, 150);
fill(0);
rect(75, 25, 50, val);
print(val);
}
}
End result: