Embedded Networking and Communications

Group Assignment:

In the group assignment, the required is to sed massage between two projects but at that moment I work alone so I decided to make a simple game using processing and my hall effect sensor from Input Devises week, basically, I will use serial communication to send a message "value" from the sensor to processing.

So this assignment was inspired by this project

After reading the processing code the mechanism to move the Flappy Bird is if the sensor value reached 0 or less it will move down if it more than 0 it will move up.

Arduino code 




const int hallPin = PB4;     // the number of the hall effect sensor pin
int hallState = 0;          // variable for reading the hall sensor status
int y = 0;
void setup() {
  // initialize the hall effect sensor pin as an input:
  pinMode(hallPin, INPUT);
  Serial.begin(9600);
}

void loop(){
  // read the state of the hall effect sensor:
  hallState = analogRead(hallPin);
  y = map(hallState, 0, 1023, -50,150 ); //convert the values from  0 , 1023 to -50,150
  Serial.println(y); // send the y value throw Serial
}


														

Important note 

when you use the sensor one of the magnetic polarity will give you values from -50 to 50 and the other polarity will change the values from 50 to 150.

last note make sure that the "COM" port for the device is the same for prossising 

Now for testing the game X"D

 

Files.