Martha MigliacioAlex Wong
Published © GPL3+

Using the Pmod DA1 with Arduino Uno

Application notes for Pmod DA1 and Arduino Uno. Outputs A1 & B1 to make square wave signals.

EasyProtip1 hour162
Using the Pmod DA1 with Arduino Uno

Things used in this project

Hardware components

Pmod DA1
Digilent Pmod DA1
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Digilent Analog Discovery 2
Recommended to see the resulting signal.
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Pmod DA1 and Arduino Uno Fritzing file

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

Pmod DA1 and Arduino Uno Fritzing Image

Fritzing image displaying the connection between the Pmod DA1 and Arduino Uno.
Pmodda1 arduinouno bb p7v9whpsvk

Pmod DA1 Signal

Visualization of the outputs of the Pmod DA1 using an Analog Discovery 2.
Pmodda1 signal fsv8ktoagb

Code

Pmod DA1 and Arduino Uno Code

Arduino
Outputs A1 and B1 Deliver square wave signals in phase opposition with a programmable period.
/************************************************************************
*
* Test of the Pmod 
*
*************************************************************************
* Description: Pmod_DA1
* Outputs A1 and B1 deliver square wave signals in phase opposition
* with a programmable period.
*
* Material
* 1. Arduino Uno
* 2. Pmod DA1
*
************************************************************************/

#define CS 10 // affectation of CS pin
#include <SPI.h> // Include library

int periode=10;
void setup()
{
 SPI.begin(); // initialization of SPI port
 SPI.setDataMode(SPI_MODE0); // configuration SPI communication in mode 0
 SPI.setClockDivider(SPI_CLOCK_DIV16); // configuration of clock at 1MHz
 pinMode(CS, OUTPUT);
}
void loop()
{
  digitalWrite(CS, LOW); // activation of CS line
  SPI.transfer(16); // send commande bits (output A active and output B inactive)
  SPI.transfer(255); // send data bits
  digitalWrite(CS, HIGH); // deactivation CS line
  delay(periode/2); // wait
  digitalWrite(CS, LOW); // activation of CS line
  SPI.transfer(12); // send commande bits (output A inactive and output B active)
  SPI.transfer(255); // send data bits
  digitalWrite(CS, HIGH); // deactivation CS line
  delay(periode/2); // wait
}

Credits

Martha Migliacio

Martha Migliacio

5 projects • 4 followers
Alex Wong

Alex Wong

5 projects • 11 followers
I work in Digilent and like creating projects
Thanks to Lextronics.

Comments