Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Code from Arduino to be in MikroC

Status
Not open for further replies.

kail123

Newbie level 4
Joined
Jan 23, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,331
Hi Guys , I have below code from Arduino and need help to change it to MikroC . the reason of this just to see how is MikroC will be changed the Function code .. i am going to use 16f877 with Osc 10 Mhz , using any port setup no issue for me , i will modify it later on . The code is controlling the speed of DC Motor with one Button .


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
int switchPin = 8;
int MotorPin = 11;
boolean lastButton = LOW;
boolean currentButton = LOW;
int MotorSpeed = 0;
 
void setup()
{
  pinMode(switchPin, INPUT);
  pinMode(MotorPin, OUTPUT);
}
 
boolean debounce(boolean last)
{
  boolean current = digitalRead(switchPin);
  if (last != current)
  {
    delay(5);
    current = digitalRead(switchPin);
  }
  return current;
}
 
void loop()
{
  currentButton = debounce(lastButton);
  if (lastButton == LOW && currentButton == HIGH)
  {
    MotorSpeed = MotorSpeed + 61;
  }
  lastButton = currentButton;
  
  if (MotorSpeed > 255) MotorSpeed = 0;
  analogWrite(MotorPin, MotorSpeed);
 
}

 
Last edited by a moderator:

I can write the code for you but you have to give me the PIC circuit because I have to know which pin connects to which component like LED, Motor, etc...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top