Things used in this project

Hardware components:
Anduino Arduino Uno
×1
Pmod dpot  51278.1456866444.500.659
Digilent Pmod DPOT
×1
Pmod ls1  67079.1456866842.500.659
Digilent Pmod LS1
×1
Software apps and online services:
Ide web
Arduino IDE

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.
pmodls1arduinouno_3wGHnOTOH8.fzz
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 CodeArduino
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

01aa44817a11ceb1a3050ebac4b68bbc
Martha Migliacio
1 project • 0 followers
Contact
Thanks to Lextronics.

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login