Paso 4: código
Utilice el IDE de arduino para subir el código a la Junta, debe modificar el IDE para que sea apoyo a la Junta un Linkit.
<p>#define HALL_SENSOR 7<br>#define LED 14//the Grove - LED is connected to D4 of Arduino void setup() { pinsInit(); } void loop() { if(isNearMagnet())//if the hall sensor is near the magnet? { turnOnLED(); } else { turnOffLED(); } } void pinsInit() { pinMode(HALL_SENSOR, INPUT); pinMode(LED,OUTPUT); } /*If the hall sensor is near the magnet whose south pole is facing up, */ /*it will return ture, otherwise it will return false. */ boolean isNearMagnet() { int sensorValue = digitalRead(HALL_SENSOR); if(sensorValue == LOW)//if the sensor value is LOW? { return true;//yes,return ture } else { return false;//no,return false } } void turnOnLED() { digitalWrite(LED,HIGH); } void turnOffLED() { digitalWrite(LED,LOW); }</p>