aarushiramesh
Published © GPL3+

Build a 4-Bit Digital to Analog Convertor using Arduino UNO

Design a Digital to Analog Converter using the R-2R Ladder circuit and Arduino UNO board/a microcontroller interface, a Beginners Project!

BeginnerFull instructions provided6,220
Build a 4-Bit Digital to Analog Convertor using Arduino UNO

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
1kOhm Resistors
×3
2kOhm Resistors
×5
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino Web Editor
Arduino Web Editor

Story

Read more

Code

Code to experiment with the DAC

Arduino
//feel free to experiment with the code by setting different inputs (1, or 0) to the Digital Pins 

//Digital to Analog Convertor Testing
//For a 4-bit DAC Circuit.

//set the delay
int timer = 100;

void setup() {
    //set the Digital Pins- D2 to D6
    for(int thisPin = 2; thisPin < 6; thisPin++){
      pinMode(thisPin, OUTPUT);
    }
    Serial.begin(9600);
}

void loop() {
    //turns the 4 Digital pins into HIGH (1) state
    //experiment by changing the 4 pin values
    for(int thisPin = 2; thisPin < 6; thisPin++){
      digitalWrite(thisPin, HIGH);
      delay(timer);
    }
    
    int sensorValue = analogRead(A0);
    // convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
    float voltage = sensorValue * (5.0 / 1023.0);
    
    // print out the analog voltage value we read
    Serial.println(voltage);
    
    //turn the pins off
    for (int thisPin = 5; thisPin >= 2; thisPin--) {
      digitalWrite(thisPin, LOW);
      delay(timer);
    }
    
}

Credits

aarushiramesh
1 project • 0 followers
Student.
Contact

Comments

Please log in or sign up to comment.