KingAbad / Autonomous_Cart_2

0 stars 3 forks source link

RGB leds aansturen mbv sensoren met PSoc 4 PIONEER KIT #33

Open ALi-Natiq opened 4 years ago

ALi-Natiq commented 4 years ago

Eerst moet de ultrasoon sensor geprogrammeerd worden met PSoc 4

thumbnail_IMG_20200328_161306

ALi-Natiq commented 4 years ago

Ultrasoon sensor is geprogrammeerd met psoc 4

ultra1

abad2

Code:

`#include "project.h"

include

include

short afstand = 0;

int main(void)
{
CyGlobalIntEnable; / Enable global interrupts. /

UART_Start();  
PWM_Start(); 
Timer_Start();

PWM_WritePeriod(255);
PWM_WriteCompare(127);

char string[1];
for(;;)
{
      if(Echo_Read() == 1)
     {        
      afstand = (Timer_ReadCounter()/100);
      itoa(afstand,string,10);
      UART_UartPutString("Afstand in cm: ");
      UART_UartPutString(string);
      UART_UartPutString("\n\r");
      Timer_WriteCounter(0);
      CyDelay(500);
    }

}  

} `

Instellingen: 1-Timer: timer0

timer

2-PWM: pwm0

pwm

3-UART: uart0

uart

ALi-Natiq commented 4 years ago

Demo (video)

demo.zip