Skeleton code. LCD, Serial, Feedback, MOSFETS
Dependencies: mbed mbed-rtos ShiftReg2 TextLCD
main.cpp@3:5665939d31ca, 2019-05-07 (annotated)
- Committer:
- mwthewsey
- Date:
- Tue May 07 14:05:31 2019 +0000
- Revision:
- 3:5665939d31ca
- Parent:
- 2:4c18a6d89f19
- Child:
- 4:020f93d35f6e
mh
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mwthewsey | 0:c63c0359492d | 1 | #include "mbed.h" |
mwthewsey | 0:c63c0359492d | 2 | #include "rtos.h" //Real Time Operating System. https://os.mbed.com/handbook/RTOS |
mwthewsey | 2:4c18a6d89f19 | 3 | #include "TextLCD.h" |
mwthewsey | 2:4c18a6d89f19 | 4 | #include "ShiftReg.h" |
mwthewsey | 0:c63c0359492d | 5 | |
mwthewsey | 2:4c18a6d89f19 | 6 | //Pinouts for the bluepill can be found here |
mwthewsey | 2:4c18a6d89f19 | 7 | //https://os.mbed.com/users/hudakz/code/STM32F103C8T6_Hello/ |
mwthewsey | 2:4c18a6d89f19 | 8 | |
mwthewsey | 2:4c18a6d89f19 | 9 | DigitalOut myled(PC_13); //Onboard LED |
mwthewsey | 2:4c18a6d89f19 | 10 | Serial PC(PB_10, PB_11); //TX, RX |
mwthewsey | 3:5665939d31ca | 11 | //TextLCD LCD(PB_12, PB_13, PB_14, PB_15, PA_8, PA_9); // rs, e, d4-d7 |
mwthewsey | 3:5665939d31ca | 12 | ShiftReg SR(PA_10, PA_12, PA_15, PA_11); //data, store, clock, output enable |
mwthewsey | 3:5665939d31ca | 13 | |
mwthewsey | 0:c63c0359492d | 14 | |
mwthewsey | 3:5665939d31ca | 15 | //DigitalOut Muscle0(PA_10); |
mwthewsey | 3:5665939d31ca | 16 | //DigitalOut Muscle1(PA_10); |
mwthewsey | 2:4c18a6d89f19 | 17 | |
mwthewsey | 3:5665939d31ca | 18 | //AnalogIn FEEDBACK_0(PB_0); |
mwthewsey | 3:5665939d31ca | 19 | //AnalogIn FEEDBACK_1(PB_1); |
mwthewsey | 0:c63c0359492d | 20 | |
mwthewsey | 2:4c18a6d89f19 | 21 | |
mwthewsey | 2:4c18a6d89f19 | 22 | int main() |
mwthewsey | 3:5665939d31ca | 23 | { |
mwthewsey | 3:5665939d31ca | 24 | /* |
mwthewsey | 3:5665939d31ca | 25 | //outen = 0; |
mwthewsey | 3:5665939d31ca | 26 | SR.ShiftByte(0x0000, ShiftReg::MSBFirst); |
mwthewsey | 3:5665939d31ca | 27 | //SR.ShiftByte(0x00,0x80); |
mwthewsey | 3:5665939d31ca | 28 | SR.Latch(); |
mwthewsey | 3:5665939d31ca | 29 | wait(0.2); |
mwthewsey | 3:5665939d31ca | 30 | SR.ShiftByte(0xF0F0, ShiftReg::MSBFirst); |
mwthewsey | 3:5665939d31ca | 31 | SR.Latch(); |
mwthewsey | 3:5665939d31ca | 32 | //outen = 0; |
mwthewsey | 3:5665939d31ca | 33 | wait(2); |
mwthewsey | 3:5665939d31ca | 34 | SR.ShiftByte(0x0000, ShiftReg::MSBFirst); |
mwthewsey | 3:5665939d31ca | 35 | SR.Latch(); |
mwthewsey | 3:5665939d31ca | 36 | */ |
mwthewsey | 3:5665939d31ca | 37 | SR.Write(0x0000); |
mwthewsey | 3:5665939d31ca | 38 | wait(1); |
mwthewsey | 3:5665939d31ca | 39 | while(1) |
mwthewsey | 3:5665939d31ca | 40 | { |
mwthewsey | 3:5665939d31ca | 41 | SR.Write(0xF0F0); |
mwthewsey | 3:5665939d31ca | 42 | wait(1); |
mwthewsey | 3:5665939d31ca | 43 | SR.Write(0x0F0F); |
mwthewsey | 3:5665939d31ca | 44 | wait(1); |
mwthewsey | 3:5665939d31ca | 45 | /* |
mwthewsey | 3:5665939d31ca | 46 | SR.ShiftBit(1); |
mwthewsey | 3:5665939d31ca | 47 | SR.Latch(); |
mwthewsey | 3:5665939d31ca | 48 | wait(0.2); |
mwthewsey | 3:5665939d31ca | 49 | for (int i = 0; i < 16; i++) { |
mwthewsey | 3:5665939d31ca | 50 | SR.ShiftBit(0); |
mwthewsey | 3:5665939d31ca | 51 | SR.Latch(); |
mwthewsey | 3:5665939d31ca | 52 | wait(0.2); |
mwthewsey | 3:5665939d31ca | 53 | } |
mwthewsey | 3:5665939d31ca | 54 | */ |
mwthewsey | 3:5665939d31ca | 55 | //myled = 1; // LED is ON |
mwthewsey | 3:5665939d31ca | 56 | //Muscle0 = 1; |
mwthewsey | 3:5665939d31ca | 57 | //wait(1); // 200 ms |
mwthewsey | 2:4c18a6d89f19 | 58 | |
mwthewsey | 3:5665939d31ca | 59 | //myled = 0; // LED is OFF |
mwthewsey | 3:5665939d31ca | 60 | //Muscle0 = 0; |
mwthewsey | 3:5665939d31ca | 61 | //wait(1); // 1 sec |
mwthewsey | 3:5665939d31ca | 62 | |
mwthewsey | 2:4c18a6d89f19 | 63 | PC.printf("troll lol lol lol lol lol lol\n\r"); |
mwthewsey | 3:5665939d31ca | 64 | //PC.printf("%.6f %.6f\n\r",FEEDBACK_0.read(),FEEDBACK_1.read()); |
mwthewsey | 3:5665939d31ca | 65 | //LCD.printf("Hello World!\n"); |
mwthewsey | 3:5665939d31ca | 66 | |
mwthewsey | 0:c63c0359492d | 67 | } |
mwthewsey | 0:c63c0359492d | 68 | } |