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.
main.cpp
00001 /** 00002 * Copyright (c)2010 ARM Ltd. 00003 * Released under the MIT License: http://mbed.org/license/mit 00004 */ 00005 00006 #include "mbed.h" 00007 #include "QEI.h" 00008 #include "Motor.h" 00009 #include "SerialRPCInterface.h" 00010 00011 //Create the interface on the USB Serial Port 00012 SerialRPCInterface SerialInterface(USBTX, USBRX); 00013 00014 QEI Encoder(p29 ,p30, NC, 48); 00015 Motor Wheel(p23, p21, p22); 00016 00017 //Create float variables 00018 float MotorOutput = 50; 00019 float Percentage = 0; 00020 00021 //Make these variables accessible over RPC by attaching them to an RPCVariable 00022 RPCVariable<float> RPCMotorOut(&MotorOutput, "MotorOutput"); 00023 RPCVariable<float> RPCPercentage(&Percentage, "Percentage"); 00024 00025 int main(){ 00026 00027 Encoder.reset(); 00028 float NoPulses; 00029 00030 while(1){ 00031 NoPulses = Encoder.getPulses(); 00032 Percentage = ((NoPulses / 48) * 100); 00033 //RPC will be used to set the value of MotorOutput. 00034 Wheel.speed((MotorOutput - 50) * 2 / 100); 00035 wait(0.005); 00036 } 00037 }
Generated on Tue Jul 12 2022 11:13:40 by
