#include "stdafx.h" #include "User_Api.h" #include "PET_Type.h" #include "time.h" void delay(int sec) { int ms = 1000 * sec; clock_t start_time = clock(); while (clock() < start_time + ms); } int main() { int i; // start portwell API PET_API_Init(); // set pin 3 & 4 as an input PET_GPIO_SetPinDirection (1, 3, 1); PET_GPIO_SetPinDirection (1, 4, 1); unsigned char greenvalue = 0; unsigned char redvalue = 0; for (i = 1; i < 20; i++) { // read pins, print values PET_GPIO_ReadPin(1, 4, &greenvalue); printf("\n Green is: %d", greenvalue); PET_GPIO_ReadPin(1, 3, &redvalue); printf("\n Red is: %d\n", redvalue); delay(200); } printf("\n"); // close API PET_API_Uninit (); }