Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 3 months ago.
How to set up SPI, I2C and Serial
I am fortuanate to have an LPC812 (8 pin) Dev board,
Similar to the Ada Fruit one: LPC800 Starter Kit
But have not had a great deal of joy with it, because MBED so far does not support it.
Please can we have some example code.
Cheers
Ceri
Question relating to:
1 Answer
10 years, 10 months ago.
<<code title = PCF8591 >>
- include "mbed.h"
- include "stdio.h"
init_adc(pin sda, pin scl, address, ADC mux, DAC value) return 1/0 (1-transmission ok)
adc(pin sda, pin scl, address, ADC mux) return ADC value
int init_adc (PinName sda, PinName scl,unsigned char addr, char mux,char dac_) { const char comm[] = {0x40+mux,dac_}; I2C p_i2c(sda,scl); return(p_i2c.write(addr,comm,2)); }
int adc (PinName sda, PinName scl,char addr) { char response[1]; I2C p_i2c(sda,scl); p_i2c.read((addr+0x01), response, 1); return(response[0]); } << / code >>