Need help for my code

I'm newbie to Arduino World. I'm using Virtual BreadBoard to emulate eight LEDs with a shift register "74595" and this is my code EightLEDs.java :

import muvium.compatibility.arduino.*;

public class EightLEDs extends Arduino{

// The setup() method runs once, when the sketch starts
int latchPin = 5;
int clockPin = 6;
int dataPin = 4;
byte leds = 0;

public void setup(){

// Your setup code goes here
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power
public void loop(){
leds = 0;
updateShiftRegister();
delay(500);
for (int i = 0; i < 8; i++)
{
bitSet(leds, i);
updateShiftRegister();
delay(500);
}
}
public void shiftDataOut(byte dataOut) {
// Shift out 8 bits LSB first, clocking each with a rising edge of the clock line
boolean pinState;
for (int i=0; i <= 7; i++) { // for each bit in dataOut send out a bit
digitalWrite(clockPin, LOW); //set clockPin to LOW prior to sending bit
// if the value of DataOut and (logical AND) a bitmask
// are true, set pinState to 1 (HIGH)
if ( dataOut & (1 << i) ) {
pinState = HIGH;
}
else {
pinState = LOW;
}
//sets dataPin to HIGH or LOW depending on pinState
digitalWrite(dataPin, pinState); //send bit out before rising edge of clock
digitalWrite(clockPin, HIGH);
}
digitalWrite(clockPin, LOW); //stop shifting out data
}
void updateShiftRegister()
{
digitalWrite(latchPin, LOW);
shiftDataOut(dataPin);
digitalWrite(latchPin, HIGH);
}

// Your loop code goes here

}

When compiling, i've got these errors :

1-if condition must be boolean and not 'int'.
2-type 'int' is not assignable to boolean.
3-cannot find method "ShiftDataOut(int)".

Any help please and thanks.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html
then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

What model arduino are you going to use and what version Arduino IDE are you using, although it looks like you are using java for some reason.

May I suggest you use the IDE and its standard layout.

Thanks... Tom.. :slight_smile:

Hi,

Thanks for you response, in fact i'm using Virtual BreadBoard with arduino toolkit (arduino uno).
This software uses Java. My Arduino IDE version is 1.6.8.

import muvium.compatibility.arduino.*;

public class EightLEDs extends Arduino{

   // The setup() method runs once, when the sketch starts
   int latchPin = 5;
   int clockPin = 6;
   int dataPin = 4;
   byte leds = 0;
   
   public void setup(){   
   
      // Your setup code goes here
      pinMode(latchPin, OUTPUT);
      pinMode(dataPin, OUTPUT);
      pinMode(clockPin, OUTPUT);
   }



   // the loop() method runs over and over again,
   // as long as the Arduino has power
   public void loop(){
      leds = 0;
      updateShiftRegister();
      delay(500);
      for (int i = 0; i < 8; i++)
      {
         bitSet(leds, i);
         updateShiftRegister();
         delay(500);
      }
   }
   public void shiftDataOut(byte dataOut) {
      // Shift out 8 bits LSB first, clocking each with a rising edge of the clock line
      boolean pinState;
      for (int i=0; i <= 7; i++) { // for each bit in dataOut send out a bit
         digitalWrite(clockPin, LOW); //set clockPin to LOW prior to sending bit
         // if the value of DataOut and (logical AND) a bitmask
         // are true, set pinState to 1 (HIGH)
         if ( dataOut & (1 << i) ) {
            pinState = HIGH;
         }
         else {
            pinState = LOW;
         }
         //sets dataPin to HIGH or LOW depending on pinState
         digitalWrite(dataPin, pinState); //send bit out before rising edge of clock
         digitalWrite(clockPin, HIGH);
      }
      digitalWrite(clockPin, LOW); //stop shifting out data
   }
      void updateShiftRegister()
      {
         digitalWrite(latchPin, LOW);
          shiftDataOut(dataPin);
         digitalWrite(latchPin, HIGH);
      }

      // Your loop code goes here

}
 if ( dataOut & (1 << i) ) {
            pinState = HIGH;
         }

That should be

 if ( dataOut & (1 < i) ) {
            pinState = HIGH;
         }

-Malhar