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.
Diff: main.cpp
- Revision:
- 4:3a9d307d26e2
- Parent:
- 3:8d9d440c1a2c
- Child:
- 5:eb65bd646089
diff -r 8d9d440c1a2c -r 3a9d307d26e2 main.cpp
--- a/main.cpp Mon Oct 26 16:44:20 2015 +0000
+++ b/main.cpp Sun Nov 08 13:39:24 2015 +0000
@@ -1,46 +1,50 @@
#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);
- EEPROM memory(I2C_SDA,I2C_SCL,0);
+DigitalIn trigger(PC_13);
+
int main()
{
-
-
- int8_t data_dummy='r';
- int8_t data[4];
- float x=0.0f,j=9785.26844;
- int16_t y=0x3321,z;
-
+ int i=1,j=1,check=0,oldtrigger=0,currenttrigger;
+ int8_t data_dummy;
+ int8_t data;
- memory.write(1,(int8_t)data_dummy);
- wait_ms(1);
-
- memory.write(2,(int8_t)'c');
- wait_ms(1);
- memory.read(1,data,2);
- wait_ms(1);
-
+ 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++;
+ }
- memory.write(10,j);
- wait_ms(1);
-
- memory.read(10,x);
- wait_ms(1);
-
-
- memory.write(1,(int16_t)y);
- wait_ms(1);
- memory.read(1,z);
- wait_ms(1);
-
- printf("read[1] = %c\n",data[0]);
- printf("read[2] = %c\n",data[1]);
-
- printf("float = %f\n",x);
-
- printf("int16 =%d\n",z);
-
+ 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;
+ }
}
\ No newline at end of file