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:
- el15tcd
- Date:
- 2018-02-19
- Revision:
- 1:c573caf40864
- Parent:
- 0:8a61e3541a5e
- Child:
- 2:042e4ea4d82c
File content as of revision 1:c573caf40864:
#include "mbed.h"
//DigitalIn trigger(p22);
//DigitalOut transmit(p28);
DigitalIn tl(p17); //change to correct board
DigitalIn tr(p18);
DigitalIn bl(p19);
DigitalIn br(p20);
Serial device(p28,p27); //tx,rx
BusOut myleds(LED4, LED3, LED2, LED1);
int buffer[4];
int temp1;
int row;
int columns;
char array[4];
char matrix[2][2];
int i;
int j;
void Array();
void Matrix();
int main()
{
myleds = 0;
device.baud(19200);
buffer[0] = 1;
buffer[1] = 0;
buffer[2] = 1;
buffer[3] = 0;
// buffer[4] = 0;
// buffer[5] = 0;
// buffer[6] = 1;
// buffer[7] = 0;
array[0] = 0;
array[1] = 0;
array[2] = 0;
array[3] = 0;
while(1) {
if (tl > 0) {
myleds = 1;
} else {
myleds = 0;
}
//Array();
Matrix();
device.putc(1);
for (int i=0; i<2; i++) {
for (int j=0; j<2; j++) {
//device.printf("%i",buffer[i]);
//device.putc(buffer[i]);
device.putc(matrix[i][j]);
}
}
//wait(1);
}
}
void Array()
{
for(i=0; i<=1 ; i=i+1) {
if (i == 0) {
if (tl > 0) {
array[0] = 1;
} else {
array[0] = 0;
}
} else if (i == 1) {
if (tr > 0) {
array[1] = 1;
} else {
array[1] = 0;
}
}
}
for(i=0; i<=1 ; i=i+1) {
if (i == 0) {
if (bl > 0) {
array[2] = 1;
} else {
array[2] = 0;
}
} else if (i == 1) {
if (br > 0) {
array[3] = 1;
} else {
array[3] = 0;
}
}
}
/*
for (row=0; row<2; row++) {
for(columns=0; columns<2; columns++) {
printf("%d ", array[row][columns]);
}
printf("\n");
}*/
//printf("\n");
}
void Matrix()
{
if (tl > 0) {
matrix[0][0] = 1;
} else {
matrix[0][0] = 0;
}
if (tr > 0) {
matrix[0][1] = 1;
} else {
matrix[0][1] = 0;
}
if (bl > 0) {
matrix[1][0] = 1;
} else {
matrix[1][0] = 0;
}
if (br > 0) {
matrix[1][1] = 1;
} else {
matrix[1][1] = 0;
}
}