GMU:Designing Utopias: Theory and Practice/Jenny Soggia: Difference between revisions
From Medien Wiki
Jenny Soggia (talk | contribs) No edit summary |
Jenny Soggia (talk | contribs) No edit summary |
||
Line 12: | Line 12: | ||
*next I followed the instructions from Magnetic Hall sensor, thats put up on this MediaWiki | *next I followed the instructions from Magnetic Hall sensor, thats put up on this MediaWiki | ||
int ledPin = 13; // choose the pin for the LED | |||
int inputPin = 3; // Connect sensor to input pin 3 | |||
int val = 0; // variable for reading the pin status | |||
void setup() { | |||
pinMode(ledPin, OUTPUT); // declare LED as output | |||
pinMode(inputPin, INPUT); // declare push button as input | |||
} | |||
void loop(){ | |||
val = digitalRead(inputPin); // read input value | |||
if (val == HIGH) { // check if the input is HIGH | |||
digitalWrite(ledPin, LOW); // turn LED OFF | |||
} else { | |||
digitalWrite(ledPin, HIGH); // turn LED ON | |||
} | |||
} | |||
[[File:HallSensor3.jpeg]] [[File:HallSensor4.jpeg]] | [[File:HallSensor3.jpeg]] [[File:HallSensor4.jpeg]] | ||
*Code was written correctly | |||
*but nothing happend with the sensor (hope I did not break it while using the wrong code of before) | |||
*noticed that there is no need for numbers to show up, the LED on the Sensor should have loght on and off. | |||
*did not work |
Revision as of 18:15, 6 December 2022
The Magnetic Hall Sensor
- first tries without help
- My mistake: used printing and reading Sensor value Code from class and connected the wires to adruino into the wrong places
- got noise and weird number readings
- but funny that it somehow worked with seeing differences in the numbers when putting the magnet closer to the sensor
- next I followed the instructions from Magnetic Hall sensor, thats put up on this MediaWiki
int ledPin = 13; // choose the pin for the LED int inputPin = 3; // Connect sensor to input pin 3 int val = 0; // variable for reading the pin status
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare push button as input
}
void loop(){
val = digitalRead(inputPin); // read input value if (val == HIGH) { // check if the input is HIGH digitalWrite(ledPin, LOW); // turn LED OFF } else { digitalWrite(ledPin, HIGH); // turn LED ON }
}
- Code was written correctly
- but nothing happend with the sensor (hope I did not break it while using the wrong code of before)
- noticed that there is no need for numbers to show up, the LED on the Sensor should have loght on and off.
- did not work