Components and supplies
Hall Effect Sensor
Arduino UNO
Apps and platforms
Arduino IDE
Project description
Code
CODE-4- FOR HOURGLASS BLINK
arduino
1const int hallPin = 12; 2const int hallPin2 = 13; 3const int hallPin3 = 11; 4 5const int ledPin = 9; 6const int ledPin2 = 6; 7const int ledPin3 = 5; 8 9// variables will change: 10int hallState = 0; 11// variable for reading the hall sensor status 12 13void setup() { 14 // initialize the LED pin as an output: 15 pinMode(ledPin, OUTPUT); 16 pinMode(ledPin2, OUTPUT); 17 pinMode(ledPin3, OUTPUT); 18 19 // initialize the hall effect sensor pin as an input: 20 pinMode(hallPin, INPUT); 21 pinMode(hallPin2, INPUT); 22 pinMode(hallPin3, INPUT); 23 24} 25 26void loop(){ 27 // read the state of the hall effect sensor: 28 hallState = digitalRead(hallPin); 29 30 if (hallState == LOW) { 31 // turn LED on: 32 digitalWrite(ledPin, HIGH); 33 } 34 else { 35 // turn LED off: 36 digitalWrite(ledPin, LOW); 37 } 38 if (digitalRead(hallPin2) == LOW) { 39 digitalWrite(ledPin2, HIGH); 40 } 41 else { 42 // turn LED off: 43 digitalWrite(ledPin2, LOW); 44 } 45 if (digitalRead(hallPin3) == LOW) { 46 digitalWrite(ledPin3, HIGH); 47 } 48 else { 49 // turn LED off: 50 digitalWrite(ledPin3, LOW); 51 } 52 53 54} 55
CODE-2- FOR INTERACTIVE CAR
arduino
1const int hallPin = 12; 2const int hallPin2 = 13; 3const int hallPin3 = 11; 4const int hallPin4 = 10;// the number of the hall effect sensor pin 5const int ledPin = 9; 6const int ledPin2 = 6; 7const int ledPin3 = 5; 8const int ledPin4 = 3;// the number of the LED pin 9// variables will change: 10int hallState = 0; 11// variable for reading the hall sensor status 12 13void setup() { 14 // initialize the LED pin as an output: 15 pinMode(ledPin, OUTPUT); 16 pinMode(ledPin2, OUTPUT); 17 pinMode(ledPin3, OUTPUT); 18 pinMode(ledPin4, OUTPUT); 19 // initialize the hall effect sensor pin as an input: 20 pinMode(hallPin, INPUT); 21 pinMode(hallPin2, INPUT); 22 pinMode(hallPin3, INPUT); 23 pinMode(hallPin4, INPUT); 24} 25 26void loop(){ 27 // read the state of the hall effect sensor: 28 hallState = digitalRead(hallPin); 29 30 if (hallState == LOW) { 31 // turn LED on: 32 digitalWrite(ledPin, HIGH); 33 } 34 else { 35 // turn LED off: 36 digitalWrite(ledPin, LOW); 37 } 38 if (digitalRead(hallPin2) == LOW) { 39 digitalWrite(ledPin2, HIGH); 40 } 41 else { 42 // turn LED off: 43 digitalWrite(ledPin2, LOW); 44 } 45 if (digitalRead(hallPin3) == LOW) { 46 digitalWrite(ledPin3, HIGH); 47 } 48 else { 49 // turn LED off: 50 digitalWrite(ledPin3, LOW); 51 } 52 if (digitalRead(hallPin4) == LOW) { 53 digitalWrite(ledPin4, HIGH); 54 } 55 else { 56 // turn LED off: 57 digitalWrite(ledPin4, LOW); 58 } 59 60} 61
CODE-1- FOR CONTROLLING A MOTOR
arduino
1int potPin = A0; 2int motorPin = 9; 3int potValue = 0; 4int motorValue = 0; 5void setup() { 6 Serial.begin(9600); 7} 8void loop() { 9 potValue = analogRead(potPin); 10 motorValue = map(potValue, 0, 1023, 0, 255); 11 analogWrite(motorPin, motorValue); 12 Serial.print("potentiometer = " ); 13 Serial.print(potValue); 14 Serial.print("\ motor = "); 15 Serial.println(motorValue); 16 delay(2); 17}
CODE-3- FOR SPINNING WHEEL
arduino
1int potPin = A0; 2int motorPin = 9; 3int potValue = 0; 4int motorValue = 0; 5const int hallPin = 12; // the number of the hall effect sensor pin 6const int ledPin = 13; // the number of the LED pin 7// variables will change: 8int hallState = 0; // variable for reading the hall sensor status 9 10void setup() { 11 Serial.begin(9600); 12 pinMode(ledPin, OUTPUT); 13 // initialize the hall effect sensor pin as an input: 14 pinMode(hallPin, INPUT); 15} 16void loop() { 17 potValue = analogRead(potPin); 18 motorValue = map(potValue, 0, 1023, 0, 255); 19 analogWrite(motorPin, motorValue); 20 Serial.print("potentiometer = " ); 21 Serial.print(potValue); 22 Serial.print("\ motor = "); 23 Serial.println(motorValue); 24 delay(2); 25 hallState = digitalRead(hallPin); 26 27 if (hallState == HIGH) { 28 // turn LED on: 29 digitalWrite(ledPin, LOW); 30 } 31 else { 32 // turn LED off: 33 digitalWrite(ledPin, HIGH); 34 35} 36} 37
CODE-2- FOR INTERACTIVE CAR
arduino
1const int hallPin = 12; 2const int hallPin2 = 13; 3const int hallPin3 = 11; 4const int hallPin4 = 10;// the number of the hall effect sensor pin 5const int ledPin = 9; 6const int ledPin2 = 6; 7const int ledPin3 = 5; 8const int ledPin4 = 3;// the number of the LED pin 9// variables will change: 10int hallState = 0; 11// variable for reading the hall sensor status 12 13void setup() { 14 // initialize the LED pin as an output: 15 pinMode(ledPin, OUTPUT); 16 pinMode(ledPin2, OUTPUT); 17 pinMode(ledPin3, OUTPUT); 18 pinMode(ledPin4, OUTPUT); 19 // initialize the hall effect sensor pin as an input: 20 pinMode(hallPin, INPUT); 21 pinMode(hallPin2, INPUT); 22 pinMode(hallPin3, INPUT); 23 pinMode(hallPin4, INPUT); 24} 25 26void loop(){ 27 // read the state of the hall effect sensor: 28 hallState = digitalRead(hallPin); 29 30 if (hallState == LOW) { 31 // turn LED on: 32 digitalWrite(ledPin, HIGH); 33 } 34 else { 35 // turn LED off: 36 digitalWrite(ledPin, LOW); 37 } 38 if (digitalRead(hallPin2) == LOW) { 39 digitalWrite(ledPin2, HIGH); 40 } 41 else { 42 // turn LED off: 43 digitalWrite(ledPin2, LOW); 44 } 45 if (digitalRead(hallPin3) == LOW) { 46 digitalWrite(ledPin3, HIGH); 47 } 48 else { 49 // turn LED off: 50 digitalWrite(ledPin3, LOW); 51 } 52 if (digitalRead(hallPin4) == LOW) { 53 digitalWrite(ledPin4, HIGH); 54 } 55 else { 56 // turn LED off: 57 digitalWrite(ledPin4, LOW); 58 } 59 60} 61
CODE-3- FOR SPINNING WHEEL
arduino
1int potPin = A0; 2int motorPin = 9; 3int potValue = 0; 4int motorValue 5 = 0; 6const int hallPin = 12; // the number of the hall effect sensor pin 7const 8 int ledPin = 13; // the number of the LED pin 9// variables will change: 10int 11 hallState = 0; // variable for reading the hall sensor status 12 13void 14 setup() { 15 Serial.begin(9600); 16 pinMode(ledPin, OUTPUT); 17 // initialize 18 the hall effect sensor pin as an input: 19 pinMode(hallPin, INPUT); 20} 21void 22 loop() { 23 potValue = analogRead(potPin); 24 motorValue = map(potValue, 0, 25 1023, 0, 255); 26 analogWrite(motorPin, motorValue); 27 Serial.print("potentiometer 28 = " ); 29 Serial.print(potValue); 30 Serial.print("\ motor = "); 31 32 Serial.println(motorValue); 33 delay(2); 34 hallState = digitalRead(hallPin); 35 36 37 if (hallState == HIGH) { 38 // turn LED on: 39 digitalWrite(ledPin, 40 LOW); 41 } 42 else { 43 // turn LED off: 44 digitalWrite(ledPin, 45 HIGH); 46 47} 48} 49
CODE-1- FOR CONTROLLING A MOTOR
arduino
1int potPin = A0; 2int motorPin = 9; 3int potValue = 0; 4int motorValue = 0; 5void setup() { 6 Serial.begin(9600); 7} 8void loop() { 9 potValue = analogRead(potPin); 10 motorValue = map(potValue, 0, 1023, 0, 255); 11 analogWrite(motorPin, motorValue); 12 Serial.print("potentiometer = " ); 13 Serial.print(potValue); 14 Serial.print("\ motor = "); 15 Serial.println(motorValue); 16 delay(2); 17}
Downloadable files
CONTROLLING VIA HALL EFFECT SENSOR
CONTROLLING VIA HALL EFFECT SENSOR
CONTROLLING VIA HALL EFFECT SENSOR
CONTROLLING VIA HALL EFFECT SENSOR
Documentation
CONTROLLING VIA HALL EFFECT SENSOR
CONTROLLING VIA HALL EFFECT SENSOR
CONTROLLING VIA HALL EFFECT SENSOR
CONTROLLING VIA HALL EFFECT SENSOR
Comments
Only logged in users can leave comments
SURYATEJA
0 Followers
•0 Projects
Table of contents
Intro
8
0