Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: PCA995xA microbit
Fork of PCA9955A_Hello by
main.cpp
00001 #include "MicroBit.h" //dem libraries tho.... don't forget 'em! (MCU specific) 00002 #include "PCA9955A.h" 00003 00004 //Allows each led driver port to be triggered on/off over serial - simply send the relevant Hex character using Putty or similar: 00005 //(0,1,2,3,4,5,6) = segments for character 1, 00006 //(7,8,9,A,B,C,D) = segments for character 2, 00007 //(E,F) = decimal points 00008 00009 PCA9955A led_cntlr(I2C_SDA0, I2C_SCL0 , 0x3f<<1); //SDA, SCL, Slave_address(option) 00010 MicroBitSerial pc(USBTX, USBRX); 00011 00012 void lightIt(int, int); //function to turn on specific LEDs 00013 void cutItA (); //function to turn off left hand LEDs 00014 void cutItB (); //function to turn off right hand LEDs 00015 void cutItC (); //function to turn off decimal point LEDs 00016 int state[16]; 00017 00018 int main() 00019 { //Set the operate enable pin low (it's inverted) 00020 led_cntlr.current( ALLPORTS, 1 ); //Set all outputs to max current 00021 00022 00023 while(1){ 00024 if (pc.readable()){ //If there's serial data available 00025 char sc = pc.getc(); //Read it 00026 int s = (int)sc; 00027 if (s > 96) 00028 s = s - 87; 00029 else if (s > 47) 00030 s = s - 48; 00031 if (s < 16){ 00032 state[s] = !state[s]; 00033 int onoff = state[s]; 00034 lightIt(s,onoff); 00035 } 00036 else if (s == 33){ 00037 cutItA(); 00038 cutItB(); 00039 cutItC(); 00040 for(int i = 0; i < 16; i++) 00041 state[i] = 0; 00042 } 00043 pc.printf("%d",s); 00044 } 00045 } 00046 } 00047 00048 void lightIt (int led, int o){ 00049 led_cntlr.pwm(led,o); 00050 } 00051 00052 void cutItA () { //When called display reset LEDs on left hand side 00053 for ( int i = 0; i < 7; i++ ){ 00054 led_cntlr.pwm(i,0); 00055 } 00056 } 00057 00058 void cutItB () { //When called display reset LEDs on right hand side 00059 for ( int i = 7; i < 14; i++ ){ 00060 led_cntlr.pwm(i,0); 00061 } 00062 } 00063 00064 void cutItC () { //When called display reset LEDs on right hand side 00065 for ( int i = 14; i < 16; i++ ){ 00066 led_cntlr.pwm(i,0); 00067 } 00068 }
Generated on Fri Jul 22 2022 12:35:09 by
1.7.2
