Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include <Wire.

h>
#include <Adafruit_MCP4725.h>
#include <LiquidCrystal.h>//

#define MCP4725In 30
Adafruit_MCP4725 MCP4725;
//setup for the LCD keypad shield
LiquidCrystal lcd(18, 19, 20, 21, 22, 23);

void setup()
{
// put your setup code here, to run once:
delay(1000);
lcd.begin(20,4);
MCP4725.begin(0x60); // The I2C Address of my module
//line 1 - Expected reading
lcd.setCursor(0,0);
lcd.print("Exp: ");
//line 2 - Actual reading
lcd.setCursor(0,1);
lcd.print("Act: ");

void loop()
{
// put your main code here, to run repeatedly:
uint32_t MCP4725_value;
int adcInput = 0;
float voltageIn = 0;
float MCP4725_reading;
for (MCP4725_value = 0; MCP4725_value < 4096; MCP4725_value = MCP4725_value +
128)
{
delay(1000);
MCP4725_reading = (5.0/4096.0) * MCP4725_value; //5.0 is your supply voltage
MCP4725.setVoltage(MCP4725_value, false);
adcInput = analogRead(MCP4725In); //module output connect to A0
voltageIn = (adcInput * 5.0 )/ 1024.0;
lcd.setCursor(7,0);
lcd.print(MCP4725_reading,3);
lcd.setCursor(7,1);
lcd.print(voltageIn,3);
}

/////////////////////
/* program input output arduino nano
by djukarna @ STKIP SURYA */

int tombol1 = A0;


int tombol2 = A1;
int tombol3 = A2;
int tombol4 = A3;
int tombol5 = A4;
int LED;

void setup()
{
for(LED=2; LED<13; LED ++)
{pinMode(LED, OUTPUT);}
pinMode(tombol1, INPUT);
pinMode(tombol2, INPUT);
pinMode(tombol3, INPUT);
pinMode(tombol4, INPUT);
pinMode(tombol5, INPUT);
}

void loop()
{
digitalWrite(12,digitalRead(tombol1));
digitalWrite(11,digitalRead(tombol2));
digitalWrite(10,digitalRead(tombol3));
digitalWrite(9,digitalRead(tombol4));
digitalWrite(8,digitalRead(tombol5));
}

//////////////////
#include <stdint.h>
#include <stdio.h>
#include <Wire.h>
#define MCP4725_ADDR 0x60 // [0000 0110]
/*
* 12 Bit DAC MCP4725 gives a range of 4096 possible values.
*
*/
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
Wire.beginTransmission(MCP4725_ADDR);
Wire.write(64); // cmd to update the DAC [0100 0000]
Wire.write(4095 >> 4); // the 8 most significant bits...
Wire.write((4095 & 15) << 4); // the 4 least significant bits...
Wire.endTransmission();
}

085270148581

You might also like