Lab 6 code.
Dependencies: mbed
Fork of WaG by
main.cpp
- Committer:
- spm71
- Date:
- 2018-02-27
- Revision:
- 13:8936b2f64aa2
- Parent:
- 11:6751b9406142
- Child:
- 14:be27f6e21a8a
File content as of revision 13:8936b2f64aa2:
/****************************************************************************** * 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 "io_pins.h" #include "display.h" #include <stdlib.h> #include <stdio.h> #include <string.h> int data_length = 16; int frequency = 1000000; DigitalOut SS(CHIP_SELECT); SPI spi(MOSI, MISO, SCLK); Serial pc(USBTX, USBRX); int main(void) { initial_setup(SS, data_length, frequency); char bcd[4]; //float command = 0x0100; int input; //char command_text[10] = "0x0"; while(1) { pc.printf("Select a digit between 0 and 9999:\n"); scanf("%d", &input); /* char cur_char = getchar(); while (cur_char < 48 or cur_char > 57) { //ask for input until 0-9 is selected pc.printf("Select a digit between 0 and 9:\n"); cur_char = getchar(); } */ while (input < 0 or input > 9999) { //ask for input until 0-9999 is selected pc.printf("You entered a number out of range\n"); pc.printf("Select a digit between 0 and 9999:\n"); scanf("%d", &input); } printf("you entered: %d\n", input); bin2bcd_array(input, bcd); /* for (int i = 0; i < 4; i++) { pc.printf("bcd: %d\n", bcd[i]); } */ send_command_to_display(bcd); } }