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: mbed
Fork of Lab_6_WaG by
Diff: main.cpp
- Revision:
- 0:ee6e5c60dd2d
- Child:
- 1:1b05289d0bf5
diff -r 000000000000 -r ee6e5c60dd2d main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Feb 20 16:39:34 2018 +0000
@@ -0,0 +1,99 @@
+/******************************************************************************
+* EECS 397
+*
+* Assignment Name: Lab 4: display_test2
+*
+* Authors: Sam Morrison and Phong Nguyen
+*
+* Purpose: Configures the board for 5-digit display
+*
+* Last Modified: 02/19/2018
+*
+******************************************************************************/
+#include "mbed.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+DigitalOut SS(PC_7);
+
+SPI spi(PA_7, PA_6, PA_5);
+Serial pc(USBTX, USBRX);
+
+int main(void) {
+ SS = 1;
+
+ spi.format(16,0);
+ spi.frequency(1000000);
+
+ SS = 0;
+ spi.write(0x0C01); //normal operation
+ SS = 1;
+
+ SS = 0;
+ spi.write(0x090F); //decode to bits 0:3
+ SS = 1;
+
+ SS = 0;
+ spi.write(0x0F00); //set to normal mode
+ SS = 1;
+
+ SS = 0;
+ spi.write(0x0A0F); //intensity set to max
+ SS = 1;
+
+ SS = 0;
+ spi.write(0x0B04); //display digits 0:4
+ SS = 1;
+
+ SS = 0;
+ spi.write(0x0100); //set digit 1 to 0
+ SS = 1;
+
+ SS = 0;
+ spi.write(0x0200); //set digit 2 to 0
+ SS = 1;
+
+ SS = 0;
+ spi.write(0x0300); //set digit 3 to 0
+ SS = 1;
+
+ SS = 0;
+ spi.write(0x0400); //set digit 4 to 0
+ SS = 1;
+
+ SS = 0;
+ spi.write(0x0500); //set digit 5 to 0
+
+ float command = 0x0100;
+ char input[4];
+ char command_text[10] = "0x0";
+ while(1) {
+ pc.printf("Select a digit between 0 and 9999:\n");
+ input = getchar();
+ while (input < 48 or input > 57) { //ask for input until 0-9 is selected
+ pc.printf("Select a digit between 0 and 9999:\n");
+ scanf("%d", &input);
+ }
+
+ command_text[3] = place + '0';
+ command_text[4] = '0';
+ command_text[5] = input;
+
+ command = atof(command_text); //converts string to float
+
+ pc.printf("command: %s\n", command_text);
+
+
+ SS = 0;
+ spi.write(command);
+ SS = 1;
+ //pc.printf("command: &f\n", commmand);
+ }
+ /*
+ SS = 0;
+ spi.write(0x0100); //set digit 0 to 0
+ SS = 1;
+ */
+}
+
\ No newline at end of file
