====Objective====
To connect 2 raspberry pis and send morse code form one and display on the other
====Prerequisites====
raspberry pie,monitor, keyboard, data cable, hdmi to usb cable, network cable
====Background====
The Raspberry Pi is a credit-card-sized single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools.[7][8][9][10][11]
The Raspberry Pi is manufactured through licensed manufacturing deals with Newark element14 (Premier Farnell), RS Components and Egoman. All of these companies sell the Raspberry Pi online.[12] Egoman produces a version for distribution solely in China and Taiwan, which can be distinguished from other Pis by their red coloring and lack of FCC/CE marks. The hardware is the same across all manufacturers.
====Code====
conduit
#include "rpi.h"
#include
int i,j,k,l;
int main()
{
if(map_peripheral(&gpio) == -1)
{
printf("Failed to map the physical GPIO registers into the virtual memory space.\n");
return -1;
}
/* INP_GPIO(17);
OUT_GPIO(7);
*/
INP_GPIO(22);
OUT_GPIO(10);
/*
INP_GPIO(9);
OUT_GPIO(11);
INP_GPIO(8);
OUT_GPIO(23);
*/
GPIO_CLR = 1 << 8;
GPIO_CLR = 1 << 9;
GPIO_CLR = 1 << 22;
GPIO_CLR = 1 << 17;
while(1)
{
i = GPIO_READ(8);
printf("%d \n", i);
if(i !=0)
{
GPIO_SET = 1 << 23;
}
else
{
GPIO_CLR = 1 << 23;
}
j = GPIO_READ(9);
printf("%d \n", j);
if(j !=0)
{
GPIO_SET = 1 <<11;
}
else
{
GPIO_CLR = 1 << 11;
}
k = GPIO_READ(22);
printf("%d \n", k);
if(k !=0)
{
GPIO_SET = 1 << 10;
}
else
{
GPIO_CLR = 1 << 10;
}
l = GPIO_READ(17);
printf("%d \n", l);
if(l !=0)
{
GPIO_SET = 1 << 7;
}
else
{
GPIO_CLR = 1 << 7;
}
}
}
#include
#include
#include "rpi.h"
int main()
{
if(map_peripheral(&gpio) == -1)
{
printf("Failed to map the physical GPIO registers into the virtual memory space.\n");
return -1;
}
INP_GPIO(23);
OUT_GPIO(23);
char morse;
printf("type a string: \n");
scanf( "%c", &morse );
while( morse != '#' )
{
if( morse == 'A' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(1480000);
printf( ".- " ) ;
}
else if( morse == 'B' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(760000);
printf( "-... " ) ;
}
else if( morse == 'C' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(760000);
printf( "-.-. " ) ;
}
else if( morse == 'D' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(1200000);
printf( "-.. " ) ;
}
else if( morse == 'E' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(2080000);
printf( ". " ) ;
}
else if( morse == 'F' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(760000);
printf( "..-. " ) ;
}
else if( morse == 'G' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(1200000);
printf( "--. " ) ;
}
else if( morse == 'H' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(760000);
printf( ".... " ) ;
}
else if( morse == 'I' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(1640000);
printf( ".. " ) ;
}
else if( morse == 'J' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(600000);
printf( ".--- " ) ;
}
else if( morse == 'K' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(1040000);
printf( "-.- " ) ;
}
else if( morse == 'L' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(760000);
printf( ".-.. " ) ;
}
else if( morse == 'M' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(600000);
printf( "-- " ) ;
}
else if( morse == 'N' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(1640000);
printf( "-. " ) ;
}
else if( morse == 'O' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(1040000);
printf( "--- " ) ;
}
else if( morse == 'P' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(760000);
printf( ".--. " ) ;
}
else if( morse == 'Q' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(600000);
printf( "--.- " ) ;
}
else if( morse == 'R' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(1200000);
printf( ".-. " ) ;
}
else if( morse == 'S' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(1200000);
printf( "... " ) ;
}
else if( morse == 'T' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(1920000);
printf( "- " ) ;
}
else if( morse == 'U' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(1040000);
printf( "..- " ) ;
}
else if( morse == 'V' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(600000);
printf( "...- " ) ;
}
else if( morse == 'W' )
{
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(3600000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(1040000);
printf( ".-- " ) ;
}
else if( morse == 'X' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(600000);
printf( "-..- " ) ;
}
else if( morse == 'Y' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(600000);
printf( "-.-- " ) ;
}
else if( morse == 'Z' )
{
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(240000);
GPIO_CLR = 1 << 23;
usleep(200000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(360000);
GPIO_SET = 1 << 23;
usleep(80000);
GPIO_CLR = 1 << 23;
usleep(760000);
printf( "--.. " ) ;
}
scanf( "%c", &morse );
}
printf( "\n" );
return 0;
}
====reflection====
we did not completely finish this project but we did get it working for the most part, just had problems with latency