Things used in this project

Code

RC_Car.inoC/C++
#include "SPI.h"
#include "Phpoc.h"

PhpocServer server(80);

char slideName;
int slideValue;

int pwm_a = 5;
int pwm_b = 6;
int dir_a = 4;
int dir_b = 7;

void setup() {
  
  pinMode(pwm_a, OUTPUT);  //Set control pins to be outputs
  pinMode(pwm_b, OUTPUT);
  pinMode(dir_a, OUTPUT);
  pinMode(dir_b, OUTPUT);
  
  analogWrite(pwm_a, 0);  //set both motors to run at (100/255 = 39)% duty cycle (slow)
  analogWrite(pwm_b, 0);  
  
  Serial.begin(9600);
  while(!Serial)
    ;

  Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
  //Phpoc.begin();

  server.beginWebSocket("remote_slide");

  Serial.print("WebSocket server address : ");
  Serial.println(Phpoc.localIP());  
}

void loop() {
  // wait for a new client:
 PhpocClient client = server.available();

  if (client) {
    String slideStr = client.readLine();

    if(slideStr)
    {
      slideName = slideStr.charAt(0);
      slideValue = slideStr.substring(1).toInt();

      Serial.print(slideName);
      Serial.print('/');
      Serial.println(slideValue);
      
     if(slideName == 'A'){
        
          Serial.println(slideValue);
          
          if(slideValue < 0) {
            digitalWrite(dir_a, HIGH);            
            slideValue = slideValue * -1 * 255 / 100;
          } else {
            digitalWrite(dir_a, LOW);    
             slideValue = slideValue * 255 / 100;      
          }
              Serial.println(slideValue);          
              analogWrite(pwm_a, slideValue);          
      }    
      
     if(slideName == 'B'){
        
          Serial.println(slideValue);
          
          if(slideValue < 0) {
            digitalWrite(dir_b, HIGH);            
            slideValue = slideValue * -1 * 255 / 100;
          } else {
            digitalWrite(dir_b, LOW);    
             slideValue = slideValue * 255 / 100;      
          }          
             Serial.println(slideValue);          
             analogWrite(pwm_b, slideValue);            
      }    
    }
  } 

}

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

PHPoC - Web-Based Thermometer
Easy
  • 88
  • 7

Full instructions

This project allows to check temperature at home from anywhere using web browser.

Arduino - Have Fun with Color Sensor
Easy
  • 208
  • 9

Full instructions

This project shows how to change color of Minion using Arduino, PHPoC WiFi Shield and color sensor.

Arduino - Web-Based Thermometer
Easy
  • 499
  • 11

Full instructions

This project allows you to check temperature at home from anywhere using web browser.

PHPoC - Web-Based MP3 Player
Easy
  • 168
  • 8

Full instructions

This project shows how to control MP3 player via webpage using PHPoC.

Electronic Voting Machine Using Arduino
Easy
  • 136
  • 5

It is an EVM using Arduino. There are five switches in all, assigned for various activities.

Using Python and Arduino MKR1000 for Secure IoT
Easy
  • 522
  • 7

Full instructions

Getting started with Python and Arduino MKR1000 for secure IoT projects.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login