#include //int Led = 6 ; // Arduino built in LED int SENSOR = 6 ; // define the Hall magnetic sensor PA6(MOSI) int val; // define numeric variables #define rxPin 1 // recieve from computer (in the board, it is TXD pin) #define txPin 0 // tell to computer (in the board, it is RXD pin) //oposite version SoftwareSerial mySerial(rxPin, txPin); void setup () { mySerial.begin(9600); // pinMode (Led, OUTPUT) ; // define LED as output pinMode (SENSOR, INPUT) ; // define the Hall magnetic sensor line as input //digitalWrite (Led, HIGH); //initialise } void loop () { val = analogRead (SENSOR) ; // read sensor line if (val < 500) // when the Hall sensor detects a magnetic field, Arduino LED lights up { mySerial.write(1); // Processing simpleRead example arduino code, fixed from this website: https://forum.arduino.cc/index.php?topic=169342.0 } else { mySerial.write((byte)0); } /* if (val < 30) // when the Hall sensor detects a magnetic field, Arduino LED lights up { // digitalWrite (Led, HIGH); mySerial.println(val); // Processing simpleRead example arduino code, fixed from this website: https://forum.arduino.cc/index.php?topic=169342.0 // mySerial.println(); } else { // digitalWrite (Led, LOW); mySerial.println(val); // mySerial.println(); }*/ delay(100); } /*// *** // *** Define the RX and TX pins. Choose any two // *** pins that are unused. Try to avoid D0 (pin 5) // *** and D2 (pin 7) if you plan to use I2C. // *** #define RX A0 // *** D3, Pin 2 #define TX A1 // *** D4, Pin 3 // *** // *** Define the software based serial port. Using the // *** name Serial so that code can be used on other // *** platforms that support hardware based serial. On // *** chips that support the hardware serial, just // *** comment this line. // *** SoftwareSerial Serial(RX, TX); void setup() { Serial.begin(9600); } /* void loop() { Serial.print(177); delay(500); } void loop() { for (int i=0; i<100; i++) { Serial.println(i); delay(500); } } */