Search Forums by tag:
Serial, mbed, compiler, ethernet, USB, I2C, SPI, interrupt, LCD, library, bug, HTTPServer, CAN, AnalogIn, adc, Power, Ticker, memory, pwm, SD Card, InterruptIn, rpc, Error, SDFileSystem, PwmOut, LocalFileSystem, UART, canbus, driver, TCP, interrupts, rtos, led, libraries, editor, timer, accelerometer, GPS, file, clock, website, C++, SD, frequency, reset, http, LPC11U24, flash, SDCard, RTC, DigitalIn, TCPSocket, problem, printf, Java, Servo, buffer, UDP, SerialPC, DMA, HTTPClient, Sleep, audio, pinball, MODSERIAL, NetServices, socket, array, compile, filesystem, RFID, beta, m3pi, write, LPC1768, multiple, newbie, keyboard, sensor, GPRS, Forum, digitalOut, assembly, debug, hardware, Speed, xbee, AnalogOut, RPCFunction, EthernetNetIf, Download, code, voltage, wait, network, C, suggestion, JTAG, keil, MATLAB, offline, Board, lwip, I2S, dead, Nokia6610, time, bluetooth, WiFly, current, tcp/ip, MODDMA, SPI Slave, pololu, robot, Communication, read, dac, string, pc, binary, filter, copy, USB Host, publish, rs232, DHCP, Host, Data Logging, windows, firmware, malloc, mp3, PCB, gcc, attach, program, fatfilesystem, class, email, arduino, stepper motor, WavePlayer, wifi, Nokia, camera, size, VGA, import, documentation, ide, linux, baud, TextLCD, Cortex-M0, M0, pointers, pullup, Relay, timing, function, latency, serial port, MIDI, compiler error codes, magjack, touch, screen, Production, client, server, stream, HID, breakout, FIFO, prototype, flashing, GPIO, sampling, Analog, display, api, ADXL345, Encoder, DSP, help, motor, sram, suggestions, PING, Terminal, link, browser, Pin, control, Eagle, Modbus, EEPROM, mac, Timeout, fopen, port, updates, usbserial, batteries, DMX, files, USBMIDI, scanf, protocol, PPP, slave, FTP, integer, noise, MODGPS, modem, float, threads, motors, for, monitor, Digital I/O, 7, Windows Serial Driver, pins, keypad, FAT, classes, webserver, delay, variables, time-triggered, c programming, labview, watchdog, post, math, Battery, LPCXpresso, MBED website, GSM, storage, nxp, mobileLCD, license, int, counter, baseboard, Assembler, Vin, rj45, registers, E289, news, i2cmaster, amoled, Compiling, connect, revision, prototype to hardware, UMTSStick, Optocoupler, Robotics, search, oscillator, glitch, Websockets, load, find, real-time, routine, format, offline compile, powersource, driverlibrary, processing, networking, ID, umts, debugging, color, BUTTON, software, PS3, Images, wave, bin, const, SNMP, OSX, supply, peripheral, sensors, data, Design, PID, version, RIT, character, freeze, USBDevice, bus, ARM, wav, SRF08, heap, output, basic, TFT, QVGA, mysql, piezo, update, ID12, Pachube, player, DigitalInOut, object, cmsis, capture, IR, slow, 1768, PSP, OS, syntax, mbed.lib, EmbeddedArtists, NMEA, paste, project, Web, GUI, UART0, firefox, SQL, wakeup, RAM, bitmap, handler, security, 3D, bugs, OLED, Temperature, not, I/O, Bidirectional, rss, wireless, delete, resolved, LED1, LIS302, getc, Safari, Wi-Fi, wiki, PinNames, accounts, PS2, BusOut, projects, RS485, pythonPlease log in to post a reply.
Hello guys,I am currently trying to display number on 7 segment LED when i enter the number using a 4 x 4 Keypad, however it seems like i just cant get it to work, I not sure why but i hope you guys can help me. Thanks in advance. Here is my code:
Code
#include "mbed.h" #include "keypad.h" // input of number BusOut SevenSegments(p27, p26, p25, p24, p23, p22, p21); BusOut Leds(p28, p29, p30); Keypad keypad(p15, p14, p13, p12, p20, p19, p17, p16); #define MAXBUS 10 #define MAXLEN 4 #define ENDKEYIX 14 char Keytable[] = { 0x30, 0x6D, 0x79, 0x00, 0x33, 0x5B, 0x5F, 0x00, 0x70, 0xFF, 0x7B, 0x00, 0x00, 0x75, 0x00, 0x00 }; char BusNumber[MAXBUS][MAXLEN]; int NumIX = 0; // Point to current index of Bus number volatile int BusIX = -1; // Point to current bus, -1, 0 .. MAXBUS - 1 volatile int CurrBusShown = -1; // Index to BusNumber for bus number being shown Ticker UpdateBusNumber; Ticker RefreshLEDs; /* * To be enabled in the main process once */ void UpdateBusNumberISR() { if (BusIX == -1) CurrBusShown = -1; else if (CurrBusShown <= BusIX) { CurrBusShown = ++CurrBusShown % MAXBUS; } } /* * To be called from a process in RTOS */ void RefreshLEDsISR() { while (1) { if (CurrBusShown == -1) Leds = 0; // Switch off all 7-segment leds else { for (int i = 0; i < MAXLEN - 1; i++) { Leds = 0x01 << i; SevenSegments = BusNumber[CurrBusShown][i]; printf("%02X ", BusNumber[CurrBusShown][i]); wait_ms(200); // Changed to Sleep(20000) in RTOS } printf("\n"); } } } /* * It is an ISR within a keypad process in RTOS */ uint32_t cbAfterInput(uint32_t keyIX) { if (BusIX == MAXBUS - 1) return 1; // No more space to store new bus number if (NumIX < MAXLEN - 1) { if (keyIX == ENDKEYIX) { NumIX = 0; ++BusIX; } else BusNumber[BusIX][NumIX++] = Keytable[keyIX]; } return 0; } int main() { UpdateBusNumber.attach(&UpdateBusNumberISR, 5.0); RefreshLEDs.attach(&RefreshLEDsISR, 0.5); memset(BusNumber, 0, MAXBUS * MAXLEN); keypad.CallAfterInput(&cbAfterInput); keypad.Start(); while (1) { printf("starting.."); wait(1.0); } }