Koda: |
#include <Wire.h> // specify use of Wire.h library
#include <Adafruit_ADS1015.h> #define MCP4725 0x62 // MCP4725 base address unsigned int val; byte buffer[3]; void setup() { Wire.begin(); // begin I2C } // end setup void loop() { buffer[0] = 0b01000000; // control byte val = analogRead(0) * 4; // read pot buffer[1] = val >> 4; // MSB 11-4 shift right 4 places buffer[2] = val << 4; // LSB 3-0 shift left 4 places Wire.beginTransmission(MCP4725); // address device Wire.write(buffer[0]); // pointer Wire.write(buffer[1]); // 8 MSB Wire.write(buffer[2]); // 4 LSB Wire.endTransmission(); // just an indicator digitalWrite(13, HIGH); delay(100); digitalWrite(13, LOW); delay(100); } // end loop |
Koda: |
Arduino:1.8.5 (Windows 7), Plošča:"Arduino Nano, ATmega328P"
C:\Users\Uros\Documents\Arduino\libraries\TinyWireM\USI_TWI_Master.cpp:23:0: warning: "F_CPU" redefined #define F_CPU 1000000UL // Sets up the default speed for delay.h ^ <command-line>:0:0: note: this is the location of the previous definition C:\Users\Uros\Documents\Arduino\libraries\TinyWireM\USI_TWI_Master.cpp: In function 'void USI_TWI_Master_Initialise()': C:\Users\Uros\Documents\Arduino\libraries\TinyWireM\USI_TWI_Master.cpp:50:3: error: 'PORT_USI' was not declared in this scope PORT_USI |= (1<<PIN_USI_SDA); // Enable pullup on SDA, to set high as released state. ^ C:\Users\Uros\Documents\Arduino\libraries\TinyWireM\USI_TWI_Master.cpp:50:19: error: 'PIN_USI_SDA' was not declared in this scope PORT_USI |= (1<<PIN_USI_SDA); // Enable pullup on SDA, to set high as released state. ^ C:\Users\Uros\Documents\Arduino\libraries\TinyWireM\USI_TWI_Master.cpp:51:19: error: 'PIN_USI_SCL' was not declared in this scope PORT_USI |= (1<<PIN_USI_SCL); // Enable pullup on SCL, to set high as released state. ^ ........ \ \ ........ ^ C:\Users\Uros\Documents\Arduino\libraries\TinyWireM\USI_TWI_Master.cpp:329:21: error: 'USIPF' was not declared in this scope if( !(USISR & (1<<USIPF)) ) ^ exit status 1 Error compiling for board Arduino Nano. This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences. |