Martha MigliacioAlex Wong
Published © GPL3+

Using the Pmod HB3 with Arduino Uno

Application notes for Pmod HB3 and Arduino Uno. In this app, a motor will be controlled and the status displayed on the serial monitor.

BeginnerProtip1 hour1,910
Using the Pmod HB3 with Arduino Uno

Things used in this project

Story

Read more

Schematics

Pmod HB3 and Arduino Uno Fritzing file

Fritzing file displaying the connection of the Pmod HB3 to the Arduino Uno.

Pmod HB3 and Arduino Uno Fritzing Image

Fritzing image displaying the connection between the Pmod HB3 and Arduino Uno.

Code

Pmod HB3 and Arduino Uno Code

Arduino
Using this code will set up the Pmod SWT and Pmod HB3 to control a motor and then display the status on the serial monitor.
/************************************************************************
*
* Test of Pmod HB3
*
*************************************************************************
* Description: Pmod_HB3
* Switch SW1 controls the stop or rotation of the motor.
* Switch SW2 controls the direction of rotation of the motor.
* The status of the motor is displayed on the serial monitor.
*
* Material
* 1. Arduino Uno
* 2. Pmod HB3 
* 3. Pmod SWT 
*
************************************************************************/
// Affectation of pins
#define DIRECTION 2
#define VALIDATION 3
#define SWT_1 4
#define SWT_2 5

boolean inter_1;
boolean inter_2;

void setup()
{
 Serial.begin(9600); // Initialization of the serial monitor
 pinMode(DIRECTION,OUTPUT); // Pin configuration
 pinMode VALIDATION,OUTPUT);
 pinMode(SWT_1,INPUT);
 pinMode(SWT_2,INPUT);
}

void loop()
{
 inter_1=digitalRead(SWT_1); // Reading switch SW1
 inter_2=digitalRead(SWT_2); // Reading switch SW2
 if (inter_1==HIGH) // stop motor
  {
   digitalWrite(DIRECTION,LOW);
   digitalWrite(VALIDATION,LOW);
   Serial.println("Le moteur est arrete"); // display in serial monitor
  }
 else // The motor is running
  {
   if (inter_2==HIGH)
   {
    digitalWrite(DIRECTION,HIGH);
    digitalWrite(VALIDATION,HIGH);
    Serial.println("Le moteur tourne dans le sens horaire");
   }
   else
   {
    digitalWrite(DIRECTION,LOW);
    digitalWrite(VALIDATION,HIGH);
    Serial.println("Le moteur tourne dans le sens anti-horaire");
   }
  }
}

Credits

Martha Migliacio

Martha Migliacio

5 projects • 18 followers
Alex Wong

Alex Wong

14 projects • 53 followers
I work in Digilent and like creating projects
Thanks to Lextronics.

Comments