Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned int readADS7828(unsigned char ads_address, unsigned char channel, bool mode){
- ads_address = ads_address >> 1 ;
- unsigned char channels[8] = {0x00, 0x40, 0x10, 0x50, 0x20, 0x60, 0x30, 0x70};
- unsigned char command = 0;
- unsigned int reading = 0;
- command = channels[channel];
- if (mode){
- command = command ^ 0x80;
- }
- Wire.beginTransmission(ads_address);
- Wire.write(command);
- Wire.endTransmission();
- delay(10);
- Wire.requestFrom(ads_address, 2);
- if (2 <= Wire.available()) {
- reading = Wire.read();
- reading = reading << 8;
- reading |= Wire.read();
- }
- return reading;
- }
Advertisement
Add Comment
Please, Sign In to add comment