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.
main.cpp
- Committer:
- Peeraya
- Date:
- 2015-11-08
- Revision:
- 4:3a9d307d26e2
- Parent:
- 3:8d9d440c1a2c
- Child:
- 5:eb65bd646089
File content as of revision 4:3a9d307d26e2:
#include "mbed.h"
#include "eeprom.h"
EEPROM memory(I2C_SDA,I2C_SCL,0);
BusIn inbutton(D8,D7,D6,D5,D4,D3,D2);
BusOut led(A1,A0,D13,D12,D11,D10,D9);
DigitalIn selectmode(PB_7);
DigitalIn trigger(PC_13);
int main()
{
    int i=1,j=1,check=0,oldtrigger=0,currenttrigger;
    int8_t data_dummy;
    int8_t data;
    
    while(1)
    {
        currenttrigger=trigger;
        
    if(selectmode==0 && oldtrigger==0 && currenttrigger==1) //0 is write mode
    {
        if(check==1){i=1;j=1;check=0;}
        data_dummy=inbutton;
        
        memory.write(i,(int8_t)data_dummy);
        wait_ms(1);
        i++;
    }
    
    if(selectmode==1 && oldtrigger==0 && currenttrigger==1)
    {   
        check=1;
        if(j<i) 
        {
            memory.read(j,data);
            wait_ms(1); 
            led = data;
            wait(1);
            
            j++;
        } 
        else
        {led=0;}
    }
        oldtrigger=currenttrigger;
    }
    
}