الوصف
طريقة التوصيل
- مخرج الأرضي في الأردوينو –> مخرج السالب (-) في الحساس
- مخرج +5V في الأردوينو –> مخرج الموجب (+) في الحساس
- أي مخرج رقمي و ليكن D10 –> مخرج S في الحساس
برنامج التشغيل
/*KY-003 Hall magnetic switch*/ int Led = 13 ; // define LED Interface int SENSOR = 10 ; // define the Hall magnetic sensor interface int val ; // define numeric variables val void setup (){ pinMode (Led, OUTPUT) ; // define LED as output interface pinMode (SENSOR, INPUT) ; // define the Hall magnetic sensor line as input } void loop (){ val = digitalRead (SENSOR) ; // read sensor line if (val == LOW) // when the Hall sensor detects magnetic field, Arduino LED is up { digitalWrite (Led, HIGH); } else { digitalWrite (Led, LOW); } }
التقييمات
لا يوجد تقييمات حالياً.