Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This code uses the digitalRead() function to read the state of the sensor pin. In the setup() function, the sensor pin is set as an input using the pinMode() function.
- In the loop() function, the sensor value is read using digitalRead() and printed to the serial port using the Serial.println() function. A short delay is added using the delay() function before the loop starts again.
- This code provides a basic framework for reading from an A3144 Hall Effect Sensor using an Arduino. You can modify the code to suit your specific requirements, such as adding threshold values or calculating the frequency of the sensor output.
- */
- // define the sensor pin
- const int SENSOR_PIN = 2;
- void setup() {
- // initialize the serial port for debugging
- Serial.begin(9600);
- // set the sensor pin as an input
- pinMode(SENSOR_PIN, INPUT);
- // print a message to the serial port
- Serial.println("A3144 Hall Effect Sensor ready!");
- }
- void loop() {
- // read the sensor value
- int sensorValue = digitalRead(SENSOR_PIN);
- // print the sensor value to the serial port
- Serial.print("Sensor value: ");
- Serial.println(sensorValue);
- // wait for a short time
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement