Martha MigliacioAlex Wong
Published © GPL3+

Using the Pmod LS1 with Arduino Uno

Application notes for Pmod LS1 and Arduino Uno. The input voltage & output level of the comparator module is displayed In the serial monitor

EasyProtip1 hour114
Using the Pmod LS1 with Arduino Uno

Things used in this project

Hardware components

Pmod DPOT
Digilent Pmod DPOT
×1
Pmod LS1
Digilent Pmod LS1
×1
Anduino Arduino Uno
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Pmod LS1, Pmod DPOT, and Arduino Uno Fritzing file

Fritzing file displaying the connection of the Pmod LS1, and Pmod DPOT to the Arduino Uno.

Pmod LS1, Pmod DPOT, and Arduino Uno Fritzing Image

Fritzing image displaying the connection of the Pmod LS1, and Pmod DPOT to the Arduino Uno.
Pmodls1arduinouno bb f4wsjqm3pj

Code

Pmod LS1 and Arduino Uno Code

Arduino
Using this code will display the input and output voltage level of the comparator in the serial monitor.
/************************************************************************
*
* Test of Pmod LS1
*
*************************************************************************
* Description: Pmod_LS1
* The output voltage of the digital potentiometer module changes from 0 to 5 V
* And the comparator module returns a high level if the voltage is
* Greater than threshold.
* The input voltage and output level of the comparator module is displayed
* In the serial monitor.
*
*
* Material
* 1. Arduino Uno
* 2. Pmod DPOT
* 3. Pmod LS1
*
************************************************************************/

#define CS 10 // Assignment of the CS pin
#define comparateur 2 // Assignment of the comparator pin
#include <SPI.h> // call library

int i;
int val=0;
float tension;

void setup()
{
 Serial.begin(9600); // initialization of serial communication
 SPI.begin(); // initialization of SPI communication
 SPI.setDataMode(SPI_MODE0); // configuration of SPI communication in mode 0
 SPI.setClockDivider(SPI_CLOCK_DIV16); // configuration of clock at 1MHz
 pinMode(CS, OUTPUT);
 pinMode(comparateur, INPUT);
}

void loop()
{
 for (i=0;i<256;i=i+1)
   {
   digitalWrite(CS, LOW); // activation of CS line
   delayMicroseconds(15);
   SPI.transfer(i); // Send variable i (i=0->Vout=0V i=255->Vout=Vcc)
   val=analogRead(A0); // conversion AN
   tension = map(val, 0, 1023, 0, 5000); // Voltage varies from 0 to 5000 for a variation of val from 0 to 255
   tension=tension/1000;
   Serial.print("i=");
   Serial.print(i);
   Serial.print('\t'); // tabulation
   Serial.print("val=");
   Serial.print(val);
   Serial.print('\t'); // tabulation
   Serial.print("Tension=");
   Serial.print(tension);
   Serial.println("V");
   digitalWrite(CS, HIGH); // deactivation of CS line
   if (digitalRead(comparateur)==HIGH)
   {
    Serial.println("La sortie du comparateur est au niveau haut");
   }
   else
   {
    Serial.println("La sortie du comparateur est au niveau bas");
   }
   delay(200);
   }
}

Credits

Martha Migliacio

Martha Migliacio

5 projects • 2 followers
Contact
Alex Wong

Alex Wong

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

Comments

Add projectSign up / Login