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.
Dependencies: mbed
Fork of Project_PokPakGame by
main.cpp
- Committer:
- Pumipachpro
- Date:
- 2015-12-05
- Revision:
- 2:8b6312dbfd2f
- Parent:
- 0:e282add6146d
- Child:
- 3:054a677aca64
File content as of revision 2:8b6312dbfd2f:
#include "mbed.h" SPI DataPack(SPI_MOSI, SPI_MISO, SPI_SCK); DigitalOut Latch(D10); AnalogIn VR0(A0); AnalogIn VR1(A1); float VR_value0,VR_value1; int Base[6][3][3]= { //[6]=[0]_base1,[1]_base2,[2]_base3,[3]_base4,[4]_base5,[5]_base6 //[3]=[0]_red,[1]_yello,[2]_green {{0x1F,0xFF,0xFF},{0x1F,0x1F,0xFF},{0xFF,0x1F,0xFF}} , {{0x8F,0xFF,0xFF},{0x8F,0x8F,0xFF},{0xFF,0x8F,0xFF}} , {{0xC7,0xFF,0xFF},{0xC7,0xC7,0xFF},{0xFF,0xC7,0xFF}} , {{0xE3,0xFF,0xFF},{0xE3,0xE3,0xFF},{0xFF,0xE3,0xFF}} , {{0xF1,0xFF,0xFF},{0xF1,0xF1,0xFF},{0xFF,0xF1,0xFF}} , {{0xF8,0xFF,0xFF},{0xF8,0xF8,0xFF},{0xFF,0xF8,0xFF}} }; void BaseColorUnder(int a,int b) { Latch=0; DataPack.write(Base[a][b][0]); wait_us(1); DataPack.write(Base[a][b][1]); wait_us(1); DataPack.write(Base[a][b][2]); wait_us(1); DataPack.write(0x01); wait_us(1); Latch=1; } void BaseColorUpper(int a,int b) { Latch=0; DataPack.write(Base[a][b][0]); wait_us(1); DataPack.write(Base[a][b][1]); wait_us(1); DataPack.write(Base[a][b][2]); wait_us(1); DataPack.write(0x80); wait_us(1); Latch=1; } //color >> red=0 , yello=1 , green=2 int BaseUnder(int color) { VR_value0 = VR0.read(); VR_value0 = VR_value0*6; if(VR_value0<=1) { //base1 BaseColorUnder(0,color); return 1; } else if(VR_value0>1&&VR_value0<=2) { //base2 BaseColorUnder(1,color); return 2; } else if(VR_value0>2&&VR_value0<=3) { //base3 BaseColorUnder(2,color); return 3; } else if(VR_value0>3&&VR_value0<=4) { //base4 BaseColorUnder(3,color); return 4; } else if(VR_value0>4&&VR_value0<=5) { //base5 BaseColorUnder(4,color); return 5; } else if(VR_value0>5&&VR_value0<=6) { //base4 BaseColorUnder(5,color); return 6; } } //color >> red=0 , yello=1 , green=2 int BaseUpper(int color) { VR_value1 = VR1.read(); VR_value1 = VR_value1*6; if(VR_value1<=1) { //base1 BaseColorUpper(0,color); return 1; } else if(VR_value1>1&&VR_value1<=2) { //base2 BaseColorUpper(1,color); return 2; } else if(VR_value1>2&&VR_value1<=3) { //base3 BaseColorUpper(2,color); return 3; } else if(VR_value1>3&&VR_value1<=4) { //base4 BaseColorUpper(3,color); return 4; } else if(VR_value1>4&&VR_value1<=5) { //base5 BaseColorUpper(4,color); return 5; } else if(VR_value1>5&&VR_value1<=6) { //base4 BaseColorUpper(5,color); return 6; } } int main() { DataPack.frequency(100000); DataPack.format(8,0); while(1) { BaseUnder(1); BaseUpper(0); } }