I made a programmable joystick

Page Splits <123
Share This Topic
Share
Subscribe/Jump Subscribe This Topic
< >
noodalls
Moderator
Joined: May 2003
Posts: 2335
From: Australia
PSN: noodalls
lizanias
Spread Tekken <3
Joined: Jun 2001
Posts: 1488
From: Indonesia
PSN: xtc_LZN
#42 “Quote” Edit Post
Thanks Noodalls for the reply.
After reading your answer...I'm more motivated to start building one.

Btw sorry for the late reply..
I was busy fixing my friends' sticks...and organizing a monthly tourney.

So, I'll let my friend see this post. And discuss with him, when he'll start the project.





Originally posted by noodalls
BTW, if you want I could send you an LCD screen and arduino with some wires to get your started.




O_O

Wow...
I don't know what to say...
Signature INDONESIAN Tekken scene = http://www.indotekken.com
ArcadePimp.com, Aussie's best Tekken site..
bloga
Kyu
Joined: Mar 2012
Posts: 1
#43 “Quote” Edit Post
hey noodalls, im making a pstick with my friend for frame testing, mind if i can use one of your 1 p codes?
if you can post it that would be awsome thanks! i got the cheapest lol the uno i think its called? not sure it only was 20 bucks so...
Signature Mains: lee, Armour king
noodalls
Moderator
Joined: May 2003
Posts: 2335
From: Australia
PSN: noodalls
#44 “Quote” Edit Post
Haven't read this thread for a while, not subscribed, so didn't realise anyone other than me had replied.

This is a code that I was using on the HRAP3. Having tried to help someone on 8wayrun make their own PStick, it's become very apparent that it's hard to help people if they don't know anything about arduino/programming. Given that this code is for an arduino mega with LCD screen with directional pad and buttons, there's no way to just upload it to a different setup and have it work. It will need lots of modifications before it does what you want. And while I'm happy to help people, I'm not going to recode the entire thing for a setup I don't have in front of me to test.

I also can't really remember what this code did exactly, although it looks reasonably well advanced.

If you just wanted to test simple things, the easiest way would be to learn digitalWrite and delays, and use that uploading one sketch at a time.

Code:

#include <LiquidCrystal.h>
int lagged ;
int time1=0
int time2;

int DNA [3600];
int RNA;
int protein [10];
int mode = -1;

int pressed;
int unpressed;
int all_unpressed=0;
int button=0//0 for none, 6 for right, 8 for up, 2 for down, 4 for left, 5 for button
int last_button=0;
LiquidCrystal lcd(894567);
int current_slot 0;
int cursor_position 0;

int i;
//int F=16822;
//int F=16683;
int F=16600;
int frame_count=0;    
    
unsigned long time;
  
int pins[10]={22,23,24,25,26,27,28,29,30,31};
//int pins[10]={55,56,57,58,59,3,4,5,6,7}; //RAP V3//**
void setup()
{
lcd.begin(16,2);
  
lcd.print("RDLUABCXYZ");
  


  for(
i=0;i<10;i++){pinMode(pins[i],OUTPUT);}
  
  
unpressed digitalRead(pins[4]);
  
pressed abs(unpressed-1);
  
  
pressed 0;
  
unpressed 1;
  for(
i=0;i10;i++){pinMode(pins[i],OUTPUT);digitalWrite(pins[
i],unpressed);}
  
delay(20);  
for (
i=0;i<10;i++){if (digitalRead(pins[i])==pressed){all_unpressed = (all_unpressed + (<< i));}}

for(
i=0;i<10;i++){digitalWrite(pins[i],unpressed);}
for(
i=0;i<360;i++){DNA[i]=all_unpressed;}//*Need to fix this, as won't work on HRAP3. all_unpressed should do it. 
  
delay(100);
}


void loop() {

  
time1=micros();


if(
mode==1)
{
RNA=DNA[frame_count];
for(
i=9;i>-1;i--){if(RNA<(<< i)){protein[i]=unpressed;}
else
{
protein[i]=pressed;RNA=(RNA-(<< i));}}
for(
i=0;i<10;i++){digitalWrite(pins[i],protein[i]);}
if(
frame_count>359){mode=-1;}}



if(
mode==2)
{
RNA 0;
for (
i=0;i<10;i++){if (digitalRead(pins[i])==pressed){RNA = (RNA+ (<< i));}}
DNA[frame_count]=RNA;
if((
RNA==0) && (frame_count==0)){frame_count--;}if(frame_count>359){mode=-1;}
}



if(
mode==0)
{
RNA 0;
for (
i=0;i<10;i++){if (digitalRead(pins[i])==pressed){RNA = (RNA+ (<< i));}}
DNA[current_slot]=RNA;
for(
i=9;i>-1;i--){lcd.setCursor(i,1);if(RNA<(<< i)){lcd.print(unpressed);}
                   if(
RNA>=(<< i)){lcd.print(pressed);RNA=(RNA-(<< i));}}
                   
                   
current_slot++;               
               
mode=-1;}





if (
analogRead(0)<50){button=6;}
if (
analogRead(0)>100 && analogRead(0)<150){button=8;}
if (
analogRead(0)>300 && analogRead(0)<350){button=2;}
if (
analogRead(0)>450 && analogRead(0)<500){button=4;}
if (
analogRead(0)>700 && analogRead(0)<750){button=5;}
if (
analogRead(0)>1000){button=0;}

if ((
button==4) && (cursor_position >0) && (last_button==0)){cursor_position--;mode=-1;}
if ((
button==6) && (cursor_position <6) && (last_button==0)){cursor_position++;mode=-1;}

if ((
button==8) && (current_slot <360) && (last_button==&& cursor_position!=6)){
      if  (
cursor_position==3){DNA[current_slot+1]=DNA[curre
nt_slot
]<img src="images/smilies/winkgrin.gif" border="0" alt="">NA[current_slot]=0;}
      if  (
cursor_position==4){DNA[current_slot+1]=DNA[curre
nt_slot
];}
      if (
cursor_position==5){for(i=359;i>=current_slot;i--){DNA[i+1]=DNA[i];}DNA[current_slot]=0;}
         
current_slot++;mode=-1;
                    
    
RNA=DNA[current_slot];for(i=9;i>-1;i--){lcd.setCursor(i,1);if(RNA<(<< i)){lcd.print(unpressed);}
    if(
RNA>=(<< i)){lcd.print(pressed);RNA=(RNA-(<< i));}}}
                   
if((
button==8) && (cursor_position==6)){F++;}
                   
if ((
button==2) && (current_slot >0) && (last_button==0) && (cursor_position!=6)){
      if (
cursor_position==3){DNA[current_slot-1]=DNA[current_slot]<img src="images/smilies/winkgrin.gif" border="0" alt="">NA[current_slot]=0;}
      if (
cursor_position==4){DNA[current_slot-1]=DNA[current_slot];}
      if (
cursor_position==5){for(i=current_slot;i<359;i++){DNA[i-1]=DNA[i];}}
          
current_slot--;mode=-1;
    
RNA=DNA[current_slot];for(i=9;i>-1;i--){lcd.setCursor(i,1);if(RNA<(<< i)){lcd.print(unpressed);}
    if(
RNA>=(<< i)){lcd.print(pressed);RNA=(RNA-(<< i));}}}

if((
button==2) && (cursor_position==6)){F--;}


if((
cursor_position==0) && (button==5) && (last_button==0))
{
mode=0;}
if((
cursor_position==1) && (button==5) && (last_button==0))
{
frame_count=-1;mode=1;}
if((
cursor_position==2) && (button==5) && (last_button==0))
{for(
i=0;i<360;i++){DNA[i]=unpressed;}frame_count=-1;mode=2;}
if((
cursor_position==3) && (button==5) && (last_button==0))
{
frame_count=-1;mode=1;}
if((
cursor_position==4) && (button==5) && (last_button==0))
{
frame_count=-1;mode=1;}
if((
cursor_position==5) && (button==5) && (last_button==0))
{
frame_count=-1;mode=1;}
if((
cursor_position==6) && (button==5) && (last_button==0))
{
frame_count=-1;mode=1;}





lcd.setCursor(13,1);lcd.print(current_slot);
lcd.setCursor(10,1);lcd.print(cursor_position);

last_button=button;
frame_count++;

time2=micros();
if ((
time2-time1)>(F)){lagged++;}
lcd.setCursor(3,0);lcd.print(lagged);//*+0
if(cursor_position<6){lcd.setCursor(11,0);lcd.print(time2-time1);}
if(
cursor_position==6){lcd.setCursor(11,0);lcd.print(F);}
//lcd.setCursor(11,0);lcd.print(all_unpressed);
//lcd.setCursor(11,0);lcd.print(1 << 1);
//DNA[current_slot]);
//lcd.setCursor(15,1);lcd.print(digitalRead(pins[4]));
//lcd.setCursor(15,1);lcd.print(pressed);
//lcd.setCursor(14,1);lcd.print(unpressed); 
//lcd.setCursor(11,0);lcd.print(F);


time2=micros();
delayMicroseconds (F-(time2-time1));
}




//for(i=0;i<10;i++){lcd.setCursor(i,0);lcd.print(protein[i]);}

//lcd.setCursor(5,1); lcd.print(RNA);
//lcd.setCursor(12,1);lcd.print("p");
//lcd.setCursor(13,1);lcd.print(pressed);
//lcd.setCursor(14,1);lcd.print("u");
//lcd.setCursor(15,1);lcd.print(unpressed);

//lcd.setCursor(10,1);lcd.print(digitalRead(pins[0]));


//lcd.setCursor(15,0);lcd.print(button);

//for (i=0;i<10;i++){lcd.setCursor(i,1);
//lcd.print(move_array[current_slot][i]);}

//lcd.setCursor(cursor_position,0);
//lcd.blink();

//if(mode==1)
//{RNA=DNA[frame_count];
//for(i=9;i>-1;i--){if(RNA<(1 << i)){digitalWrite(pins[i],unpressed);}
//else //if(RNA>=(1 << i))
  //               {digitalWrite(pins[i],pressed);RNA=(RNA-(1 << i));}
    //             }if(frame_count>359){mode=-1;}}
noodalls
Moderator
Joined: May 2003
Posts: 2335
From: Australia
PSN: noodalls
#45 “Quote” Edit Post
The reason I came to this thread today is I made a few additions to my code, allowing the Pstick to respond to the hauppauge HD PVR starting capture (using a light dependent resistor). This is part of capture short but accurate 60fps for frame data. The results are something like the below (look at them using avidemux or sony vegas).

http://www.mediafire.com/?dt702903s02z9dm

60fps, hit analysis on etc. Normally 50F until the moves start, then 100F between each set. Five reps, one blocked, one on hit, one on CH, then two further sets for anything in particular (e.g. confirming that the hit analysis time matches the actual recovery time). At the moment all the additonal inputs (not the move itself and not the position reset) are done by hand, and while this could change, it's probably easier to just leave it like this.
noodalls
Moderator
Joined: May 2003
Posts: 2335
From: Australia
PSN: noodalls
#46 “Quote” Edit Post
Have rewritten a lot of the code, seems a lot more time accurate now. Double checked against some old visually tested frame data, seems accurate enough to test without recording videos.
noodalls
Moderator
Joined: May 2003
Posts: 2335
From: Australia
PSN: noodalls
#47 “Quote” Edit Post
Rejigged it so that it will work "out of the box" with arduino mega + LCD keypad shield. Will upload a video soon to show it.

http://www.youtube.com/watch?v=MBXa_1dYSJo

Arduino duemilanove / uno version
8 pins 1 player support


Code:

#include <LiquidCrystal.h>
 
LiquidCrystal lcd(894567);      //sets up the pins for the LCD. Note, cannot use 9 or 10 as these are used by the interrupt timer
 //int backLight=13;
  //int pins[10]={15,16,17,18,19,2,3,11,12,13};     //**
 
int controller_used=1;
 
//int p1[] = {22,24,26,28,30,32,34,36};
 
int p1[] = {15,16,17,18,19,2,3,11};
 

  
 
int P1=1;

 
int invert_controls=0;
 
int button=0int last_button;
 
byte record1[360]; 
 
int loop_frame=148int loop_number=3int repetition=0;
 
unsigned long time1unsigned long time2unsigned long time3unsigned long time4;
 
int lag=0;
 
int mode = -1;
 
int current_slot 0int cursor_position 0;
 
int pressed=0int unpressed=1int all_unpressed=255;
 
int F=16656int frame_count=0;
 
int n;

  
void setup() {

pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
digitalWrite(12,HIGH);
digitalWrite(13,LOW);

   
 for(
n=0;n<8;n++)
  {
pinMode(p1[n],OUTPUT);
   
digitalWrite(p1[n],unpressed); } 
   
 
lcd.begin(16,2);
 
Serial.begin(115200);
 for(
n=0;n<361;n++){record1[n]=all_unpressed; }

}
void dispP1(){
   for(
n=0;n<8;n++){lcd.setCursor(n,1);lcd.print(bitRead(record1[current_slot],n));
                    }}


void loop() {
  
time2=micros();
  if((
time2)>(time1+F)) {
    
time1=micros();
       
  if(
mode==1) {time4=(micros()-time3);time3=micros();Serial.println(time4);
    if(
P1==1){for(n=0;n<8;n++)
      {
digitalWrite(p1[n],(bitRead(record1[frame_count],
n)));
      }}
    
    if(
frame_count>359){mode=-1;for(n=0;n<8;n++)
     {
digitalWrite(p1[n],unpressed); }} 
     } 


  if(
mode==3) {
    if(
P1==1){for(n=0;n<8;n++)
      {
digitalWrite(p1[n],(bitRead(record1[frame_count],
n)));
      }}
  
 
  if((
frame_count==loop_frame) && (repetition>0))
     {
repetition--;frame_count=-1;}

  if(
frame_count>359){mode=-1;for(n=0;n<8;n++)
     {
digitalWrite(p1[n],unpressed); }}
    }



  if(
mode==2) {
     if(
P1==1){for(n=0;n8;n++){bitWrite(record1[frame_count],n,digitalRead
(p1[n]));
                                  }}
     
     if(
frame_count>359){mode=-1;}
}


  if(
mode==0){
     if(
P1==1){for(n=0;n8;n++){bitWrite(record1[current_slot],n,digitalRea
d
(p1[n]));
                                }}
     if(
P1==1){dispP1();}  
     
current_slot++;delay(300);
     if(
P1==1){dispP1();} 
      
mode=-1;}


    
  if (
analogRead(0)<50){button=6;}
  if (
analogRead(0)>100 && analogRead(0)<200){button=8;}
  if (
analogRead(0)>300 && analogRead(0)<350){button=2;}
  if (
analogRead(0)>450 && analogRead(0)<550){button=4;}
  if (
analogRead(0)>700 && analogRead(0)<750){button=5;}
  if (
analogRead(0)>1000){button=0;}

  if (
button==4){
    if ((
cursor_position>0) && (last_button==0)){cursor_position--;mode=-1;}
    

  }
  
  if (
button==6){
    if((
cursor_position==9) && (last_button==0)){
      if (
p1[0]==15){invert_controls=1;}
      if (
p1[0]==16){invert_controls=2;}
      if(
invert_controls==2) {p1[0]=15p1[1]=16;}
      if(
invert_controls==1) {p1[0]=16p1[1]=15;}
      
invert_controls=0;
       
//15,16,17,18,19,2,3,11
    
}
  
    if((
cursor_position <9) && (last_button==0)){cursor_position++;mode=-1;}
     
 }


  if(
button==8){
    if((
cursor_position==0) && (last_button==0) && (current_slot<359)){
          
current_slot++;mode=-1;
          
          if(
P1==1) {dispP1();} }
   
   if((
cursor_position==1) && (last_button==0) && (current_slot<359)){
          
current_slot++;mode=-1;
          
          if(
P1==1) {dispP1();} }
   
   if((
cursor_position==2) && (last_button==0) && (current_slot<359)){
          
current_slot++;mode=-1;

          if(
P1==1) {dispP1();} }
   
   if((
cursor_position==3) && (last_button==0) && (current_slot<359)){
     if(
P1==1) {record1[current_slot+1]=record1[current_slot]; record1[current_slot]=all_unpressed;
                }
     
                  
current_slot++;mode=-1;
     
     if(
P1==1){dispP1();}}
   
   if((
cursor_position==4) && (last_button==0) && (current_slot<359)){             
     if(
P1==1) {record1[current_slot+1]=record1[current_slot];
                 }     
     
                 
current_slot++;mode=-1;
     
      if(
P1==1){dispP1();} }
   
   if((
cursor_position==5) && (last_button==0) && (current_slot<359)){
     if(
P1==1) {for(n=359;n>=current_slot;n--){record1[n+1]=record1[n];}
                                          
record1[current_slot]=all_unpressed;}
     
      
current_slot++;mode=-1;
      
      if(
P1==1){dispP1();}}
  
    if(
cursor_position==6){F++;}

    if((
cursor_position==7) && (loop_frame<359))
      {
delay(50);loop_frame++;}                   
 
    if((
cursor_position==8) && (loop_number<40) && (last_button==0))
      {
loop_number++;}
     
    if(
cursor_position==9){
      
unpressed=1;pressed=0;all_unpressed=255;
      for(
n=0;n<8;n++){
       
digitalWrite(p1[n],unpressed); } 

      for(
n=0;n<361;n++){record1[n]=all_unpressed; }}  
  
  }

                  
  if ((
button==2)){
    if ((
cursor_position==0) && (last_button==0) && (current_slot>0)){
     
current_slot--;mode=-1;
     
     if(
P1==1){dispP1();}}

    if ((
cursor_position==1) && (last_button==0) && (current_slot>0)){
     
current_slot--;mode=-1;
     
     if(
P1==1){dispP1();}}

    if ((
cursor_position==2) && (last_button==0) && (current_slot>0)){
     
current_slot--;mode=-1;
     
     if(
P1==1){dispP1();}}    
    
    if ((
cursor_position==3) && (current_slot>0) && (last_button==0)){
      if(
P1==1) {record1[current_slot-1]=record1[current_slot]; record1[current_slot]=all_unpressed;
                 }
      
            
current_slot--;mode=-1;
     
     if(
P1==1){dispP1();}}
    
    if ((
cursor_position==4) && (current_slot>0) && (last_button==0)){ 
      if (
P1==1) {record1[current_slot-1]=record1[current_slot];
                                          }
     
     
current_slot--;mode=-1;
   
     if(
P1==1){dispP1();}}
  
  if ((
cursor_position==5) && (current_slot>0) && (last_button==0)){
    if (
P1==1) {for(n=current_slot;n<359;n++){record1[n-1]=record1[n];}}
    
     
current_slot--;mode=-1;

     if(
P1==1){dispP1();}  
 }    
                  
                
  if(
cursor_position==6){F--;}
  
  if((
cursor_position==7) && (loop_frame>0))
     {
delay(50);loop_frame--;}
  
  if((
cursor_position==8) && (loop_number>0) && (last_button==0))
    {
loop_number--;}

  if(
cursor_position==9){
      
unpressed=0;pressed=1;all_unpressed=0;
      for(
n=0;n<8;n++){
       
digitalWrite(p1[n],unpressed); } 

      for(
n=0;n<361;n++){record1[n]=all_unpressed; }}

  }

  if(
button==5){
    if((
cursor_position==0) && (last_button==0))
      {
mode=0;}
    
    if((
cursor_position==1) && (last_button==0))
      {
frame_count=-1;mode=1;}
    
    if((
cursor_position==2) && (last_button==0)){
        if(
P1==1)
          {for(
n=0;n<360;n++){record1[n]=all_unpressed;}frame_count=-1;mode=2;}
        }

    if((
cursor_position==3) && (last_button==0))
      {
frame_count=-1;mode=1;}
    
    if((
cursor_position==4) && (last_button==0))
      {
frame_count=-1;mode=1;}
    
    if((
cursor_position==5) && (last_button==0))
      {
frame_count=-1;mode=1;}

    if((
cursor_position==7) && (last_button==0))
      {
repetition=loop_number;frame_count=-1;mode=3;}

    if((
cursor_position==8) && (last_button==0))
      {
repetition=loop_number;frame_count=-1;mode=3;}

    if(
cursor_position==9)
      {if(
P1==1){for(n=0;n<360;n++){record1[n]=all_unpressed;}frame_count=-1;cursor_position=0;current_slot=0;}
       
       
loop_frame=148;loop_number=3;lag=0;lcd.clear();}


  }
  

  


  
//CUT HERE TO SPEED UP LCD
     
lcd.setCursor(0,0);lcd.print(current_slot);
     
lcd.setCursor(4,0);lcd.print(cursor_position);
     
lcd.setCursor(7,0);lcd.print(loop_number); 
     
lcd.setCursor(10,0);lcd.print(loop_frame);

     if(
cursor_position==6){lcd.setCursor(11,1);lcd.print(F);}
    
   

     
time2=micros();
//CUT HERE TO SPEED UP LCD     
     

     
     
frame_count++;
     
last_button=button;

  }
  }


Last edited by noodalls on Jun 5th, 2012 at 04:48

noodalls
Moderator
Joined: May 2003
Posts: 2335
From: Australia
PSN: noodalls
#48 “Quote” Edit Post
Arduino mega version
32 pins, 2P support

Code:

#include <LiquidCrystal.h>
 
LiquidCrystal lcd(894567);      

 
int controller_used=1;
 
int p1[] = {22,24,26,28,30,32,34,36};
 
int p2[] = {23,25,27,29,31,33,35,37};
 
int p3[] = {38,40,42,44,46,48,50,52};
 
int p4[] = {39,41,43,45,47,49,51,53};
  
 
int invert_controls=0;
 
int P1=0;
 
int P2=0;

 
int button=0int last_button;
 
byte record1[360]; byte record2[360];
 
byte record3[360]; byte record4[360];
 
int loop_frame=148int loop_number=3int repetition=0;
 
unsigned long time1unsigned long time2unsigned long time3unsigned long time4;
 
int lag=0;
 
int mode = -1;
 
int current_slot 0int cursor_position 0;
 
int pressed=0int unpressed=1int all_unpressed=255;
 
int F=16656int frame_count=0;
 
int n;


  
void setup() {

 for(
n=62;n<66;n++){pinMode(n,OUTPUT);digitalWrite(n,HIGH);}
 for(
n=66;n<70;n++){pinMode(n,OUTPUT);digitalWrite(n,LOW);}
    
 for(
n=0;n<8;n++)
   {
pinMode(p1[n],OUTPUT);pinMode(p2[n],OUTPUT);pinMo
de
(p3[n],OUTPUT);pinMode(p4[n],OUTPUT);
   
digitalWrite(p1[n],unpressed); digitalWrite(p2[n],unpressed);
    
digitalWrite(p3[n],unpressed);digitalWrite(p4[n],u
npressed
);} 
   
 
lcd.begin(16,2);
 
Serial.begin(115200);
 for(
n=0;n<361;n++){record1[n]=all_unpressedrecord2[n]=all_unpressed;
                    
record3[n]=all_unpressedrecord4[n]=all_unpressed;}
}

void dispP1(){
   for(
n=0;n<8;n++){lcd.setCursor(n,1);lcd.print(bitRead(record1[current_slot],n));
                    
lcd.setCursor(n+8,1);lcd.print(bitRead(record3[current_slot],n));}}
void dispP2(){
   for(
n=0;n<8;n++){lcd.setCursor(n,1);lcd.print(bitRead(record2[current_slot],n));
                    
lcd.setCursor(n+8,1);lcd.print(bitRead(record4[current_slot],n));}}

void loop() {
  
time2=micros();
  if((
time2)>(time1+F)) {
    
time1=micros();
       
  if(
mode==1) {time4=(micros()-time3);time3=micros();Serial.println(time4);
    if(
P1==1){for(n=0;n<8;n++)
      {
digitalWrite(p1[n],(bitRead(record1[frame_count],
n)));
       
digitalWrite(p3[n],(bitRead(record3[frame_count],n
)));}}
    if(
P2==1){for(n=0;n<8;n++)
      {
digitalWrite(p2[n],(bitRead(record2[frame_count],
n)));
       
digitalWrite(p4[n],(bitRead(record4[frame_count],n
)));}}
    if(
frame_count>359){mode=-1;for(n=0;n<8;n++)
     {
digitalWrite(p1[n],unpressed); digitalWrite(p2[n],unpressed);
      
digitalWrite(p3[n],unpressed); digitalWrite(p4[n],unpressed);}} 
     } 


  if(
mode==3) {
    if(
P1==1){for(n=0;n<8;n++)
      {
digitalWrite(p1[n],(bitRead(record1[frame_count],
n)));
       
digitalWrite(p3[n],(bitRead(record3[frame_count],n
)));}}
  if(
P2==1){for(n=0;n<8;n++)
      {
digitalWrite(p2[n],(bitRead(record2[frame_count],
n)));
       
digitalWrite(p4[n],(bitRead(record4[frame_count],n
)));}}
 
  if((
frame_count==loop_frame) && (repetition>0))
     {
repetition--;frame_count=-1;}

  if(
frame_count>359){mode=-1;for(n=0;n<8;n++)
     {
digitalWrite(p1[n],unpressed); digitalWrite(p2[n],unpressed);
      
digitalWrite(p3[n],unpressed); digitalWrite(p4[n],unpressed);}}
    }



  if(
mode==2) {
     if(
P1==1){for(n=0;n8;n++){bitWrite(record1[frame_count],n,digitalRead
(p1[n]));
                                   
bitWrite(record3[frame_count],n,digitalRead(p3[n])
);}}
     if(
P2==1){for(n=0;n8;n++){bitWrite(record2[frame_count],n,digitalRead
(p2[n]));
                                  
bitWrite(record4[frame_count],n,digitalRead(p4[n])
);}}
     if(
frame_count>359){mode=-1;}
}


  if(
mode==0){
     if(
P1==1){for(n=0;n8;n++){bitWrite(record1[current_slot],n,digitalRea
d
(p1[n]));
                                 
bitWrite(record3[current_slot],n,digitalRead(p3[n]
));}}
     if(
P2==1){for(n=0;n8;n++){bitWrite(record2[current_slot],n,digitalRea
d
(p2[n]));
                                
bitWrite(record2[current_slot],n,digitalRead(p2[n]
));}}

     if(
P2==1){dispP2();}
     if(
P1==1){dispP1();}  
                     
     
current_slot++;delay(300);
      
     if(
P2==1){dispP2();}
     if(
P1==1){dispP1();} 
      
mode=-1;}


    
  if (
analogRead(0)<50){button=6;}
  if (
analogRead(0)>100 && analogRead(0)<200){button=8;}
  if (
analogRead(0)>300 && analogRead(0)<350){button=2;}
  if (
analogRead(0)>450 && analogRead(0)<550){button=4;}
  if (
analogRead(0)>700 && analogRead(0)<750){button=5;}
  if (
analogRead(0)>1000){button=0;}

  if (
button==4){
    if ((
cursor_position>0) && (last_button==0)){cursor_position--;mode=-1;}
    if ((
cursor_position==0) &&  (last_button==0)){controller_used++;if(controller_
used
>3){controller_used=1;}}}
 
 
  if(
controller_used==1){P1=1;P2=0;}
  if(
controller_used==2){P1=0;P2=1;}
  if(
controller_used==3){P1=1;P2=1;}
  
  if (
button==6){
    if((
cursor_position==9) && (last_button==0)){
      if((
P1==1)&&(p1[0]==22)){invert_controls=1;}
      if((
P1==1) && (p1[0]==24)){invert_controls=2;}
      if(
invert_controls==1) {p1[0]=24p1[1]=22;}
      if(
invert_controls==2) {p1[0]=22p1[1]=24;}
      
invert_controls=0;
      
      if((
P2==1) && (p2[0]==23)){invert_controls=3;}
      if((
P2==1) && (p2[0]==25)){invert_controls=4;}
      if(
invert_controls==3) {p2[0]=25p2[1]=23;}
      if(
invert_controls==4) {p2[0]=23p2[1]=25;}  
    
    
invert_controls=0;
    
    }

    
   if((
cursor_position <9) && (last_button==0)){cursor_position++;mode=-1;}}


  if(
button==8){
    if((
cursor_position==0) && (last_button==0) && (current_slot<359)){
          
current_slot++;mode=-1;
          if(
P2==1) {dispP2();}
          if(
P1==1) {dispP1();} }
   
   if((
cursor_position==1) && (last_button==0) && (current_slot<359)){
          
current_slot++;mode=-1;
          if(
P2==1) {dispP2();}
          if(
P1==1) {dispP1();} }
   
   if((
cursor_position==2) && (last_button==0) && (current_slot<359)){
          
current_slot++;mode=-1;
          if(
P2==1) {dispP2();}
          if(
P1==1) {dispP1();} }
   
   if((
cursor_position==3) && (last_button==0) && (current_slot<359)){
     if(
P1==1) {record1[current_slot+1]=record1[current_slot]; record1[current_slot]=all_unpressed;
                
record3[current_slot+1]=record3[current_slot]; record3[current_slot]=all_unpressed;}
     if(
P2==1) {record2[current_slot+1]=record2[current_slot]; record2[current_slot]=all_unpressed;
                
record4[current_slot+1]=record4[current_slot]; record4[current_slot]=all_unpressed;}
                  
current_slot++;mode=-1;
     if(
P2==1){dispP2();}
     if(
P1==1){dispP1();}}
   
   if((
cursor_position==4) && (last_button==0) && (current_slot<359)){             
     if(
P1==1) {record1[current_slot+1]=record1[current_slot];
                 
record3[current_slot+1]=record3[current_slot];}     
     if(
P2==1)  {record2[current_slot+1]=record2[current_slot];
                 
record4[current_slot+1]=record4[current_slot];}
                 
current_slot++;mode=-1;
      if(
P2==1){dispP2();}
      if(
P1==1){dispP1();} }
   
   if((
cursor_position==5) && (last_button==0) && (current_slot<359)){
     if(
P1==1) {for(n=359;n>=current_slot;n-- ){record1[n+1]=record1[n];record3[n+1]=record3[n];
}
                                           
record1[current_slot]=all_unpressed;record3[curren
t_slot
]=all_unpressed;}
     if (
P2==1) {for(n=359;n>=current_slot;n-- ){record2[n+1]=record2[n];record4[n+1]=record4[n];
}
                                             
record2[current_slot]=all_unpressed;record4[curren
t_slot
]=all_unpressed;}
      
current_slot++;mode=-1;
      if(
P2==1){dispP2();}
      if(
P1==1){dispP1();}}
  
    if(
cursor_position==6){F++;}

    if((
cursor_position==7) && (loop_frame<359))
      {
delay(50);loop_frame++;}                   
 
    if((
cursor_position==8) && (loop_number<40) && (last_button==0))
      {
loop_number++;}
     
    if(
cursor_position==9){
      
unpressed=1;pressed=0;all_unpressed=255;
      for(
n=0;n<8;n++){
       
digitalWrite(p1[n],unpressed); digitalWrite(p2[n],unpressed);
       
digitalWrite(p3[n],unpressed); digitalWrite(p4[n],unpressed);} 

      for(
n=0;n<361;n++){record1[n]=all_unpressedrecord2[n]=all_unpressed;
                          
record3[n]=all_unpressed;record4[n]=all_unpressed;
}}  
  
  }

                  
  if ((
button==2)){
    if ((
cursor_position==0) && (last_button==0) && (current_slot>0)){
     
current_slot--;mode=-1;
     if(
P2==1){dispP2();}
     if(
P1==1){dispP1();}}

    if ((
cursor_position==1) && (last_button==0) && (current_slot>0)){
     
current_slot--;mode=-1;
     if(
P2==1){dispP2();}
     if(
P1==1){dispP1();}}

    if ((
cursor_position==2) && (last_button==0) && (current_slot>0)){
     
current_slot--;mode=-1;
     if(
P2==1){dispP2();}
     if(
P1==1){dispP1();}}    
    
    if ((
cursor_position==3) && (current_slot>0) && (last_button==0)){
      if(
P1==1) {record1[current_slot-1]=record1[current_slot]; record1[current_slot]=all_unpressed;
                 
record3[current_slot-1]=record3[current_slot]; record3[current_slot]=all_unpressed;}
      if(
P2==1)  {record2[current_slot-1]=record2[current_slot]; record2[current_slot]=all_unpressed;
                  
record4[current_slot-1]=record4[current_slot]; record4[current_slot]=all_unpressed;}
            
current_slot--;mode=-1;
     if(
P2==1){dispP2();}
     if(
P1==1){dispP1();}}
    
    if ((
cursor_position==4) && (current_slot>0) && (last_button==0)){ 
      if (
P1==1) {record1[current_slot-1]=record1[current_slot];
                                          
record3[current_slot-1]=record3[current_slot];}
      if (
P2==1) {record2[current_slot-1]=record2[current_slot];
                                          
record4[current_slot-1]=record4[current_slot];}
     
current_slot--;mode=-1;
     if(
P2==1){dispP2();}
     if(
P1==1){dispP1();}}
  
  if ((
cursor_position==5) && (current_slot>0) && (last_button==0)){
    if (
P1==1) {for(n=current_slot;n<359;n++){record1[n-1]=record1[n];record3[n-1]=record3[n];}}
    if (
P2==1) {for(n=current_slot;n<359;n++){record2[n-1]=record2[n];record4[n-1]=record4[n];}}
     
current_slot--;mode=-1;
     if(
P2==1){dispP2();}
     if(
P1==1){dispP1();}  
 }    
                  
                
  if(
cursor_position==6){F--;}
  
  if((
cursor_position==7) && (loop_frame>0))
     {
delay(50);loop_frame--;}
  
  if((
cursor_position==8) && (loop_number>0) && (last_button==0))
    {
loop_number--;}

  if(
cursor_position==9){
      
unpressed=0;pressed=1;all_unpressed=0;
      for(
n=0;n<8;n++){
       
digitalWrite(p1[n],unpressed); digitalWrite(p2[n],unpressed);
       
digitalWrite(p3[n],unpressed); digitalWrite(p4[n],unpressed);} 

      for(
n=0;n<361;n++){record1[n]=all_unpressedrecord2[n]=all_unpressed;
                         
record3[n]=all_unpressedrecord4[n]=all_unpressed;}}

  }

  if(
button==5){
    if((
cursor_position==0) && (last_button==0))
      {
mode=0;}
    
    if((
cursor_position==1) && (last_button==0))
      {
frame_count=-1;mode=1;}
    
    if((
cursor_position==2) && (last_button==0)){
        if(
P1==1)
          {for(
n=0;n360;n++){record1[n]=all_unpressed;record3[n]=all_u
npressed
;}frame_count=-1;mode=2;}
        if(
P2==1)
          {for(
n=0;n360;n++){record2[n]=all_unpressed;record4[n]=all_u
npressed
;}frame_count=-1;mode=2;}}

    if((
cursor_position==3) && (last_button==0))
      {
frame_count=-1;mode=1;}
    
    if((
cursor_position==4) && (last_button==0))
      {
frame_count=-1;mode=1;}
    
    if((
cursor_position==5) && (last_button==0))
      {
frame_count=-1;mode=1;}

    if((
cursor_position==7) && (last_button==0))
      {
repetition=loop_number;frame_count=-1;mode=3;}

    if((
cursor_position==8) && (last_button==0))
      {
repetition=loop_number;frame_count=-1;mode=3;}

    if(
cursor_position==9)
      {if(
P1==1){for(n=0;n360;n++){record1[n]=all_unpressed;record3[n]=all_u
npressed
;}frame_count=-1;cursor_position=0;current_slot=0;}
       if(
P2==1){for(n=0;n360;n++){record2[n]=all_unpressed;record4[n]=all_u
npressed
;}frame_count=-1;cursor_position=0;current_slot=0;}
       
loop_frame=148;loop_number=3;lag=0;lcd.clear();}


  }

  


  
//CUT HERE TO SPEED UP LCD
     
lcd.setCursor(0,0);lcd.print(current_slot);
     
lcd.setCursor(4,0);lcd.print(cursor_position);
     
lcd.setCursor(7,0);lcd.print(loop_number); 
     
lcd.setCursor(10,0);lcd.print(loop_frame);
     
lcd.setCursor(14,0);lcd.print(P1);
     
lcd.setCursor(15,0);lcd.print(P2); 
     if(
cursor_position==6){lcd.setCursor(11,1);lcd.print(F);}
     if(
cursor_position>2){lcd.setCursor(14,0);lcd.print("     ");}
     
     
time2=micros();
//CUT HERE TO SPEED UP LCD     
     
     
     
frame_count++;
     
last_button=button;

  }
  }
noodalls
Moderator
Joined: May 2003
Posts: 2335
From: Australia
PSN: noodalls
#49 “Quote” Edit Post
Been in Japan for a few weeks, gave me time to think without being able to code, so had a session of coding away on return. Lots of little changes. Ready for TTT2 now.

Code:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,8,5,4,3,2);     
int backLight=13;     

 
int controller_used=1;
   
int pins[] = {54,55,56,57,58,59,64,63,62};//ABLUDR 
 
int p1[] = {38,39,40,41,45,46,50,51}; //P1 UDRLABXY
 
int p3[] = {47,52,48,53,44,42,43,44};
 
int p2[] = {22,23,24,25,29,30,34,35};
 
int p4[] = {31,36,32,37,28,26,27,28};
  
 
int invert_controls=0;
 
int P1=0;
 
int P2=0;

 
int button=0int last_button;
 
byte record1[1200]; byte record2[1200];
 
byte record3[1200]; byte record4[1200];
 
int loop_frame=148int loop_number=3int repetition=0;
 
unsigned long time1unsigned long time2unsigned long time3unsigned long time4;
 
int lag=0;
 
int mode = -1;
 
int current_slot 0int cursor_position 0;
 
int pressed=0int unpressed=1int all_unpressed=255;int all_pressed=0;
 
int F=16656int frame_count=0;
 
int n;


  
void setup() {

  
pinMode(backLight,OUTPUT);             //Turns on the backlight for the LCD
digitalWrite(backLight,HIGH);
  
  
pinMode(69,INPUT);digitalWrite(69,HIGH);
  
   for(
n=0;n<9;n++)
  {
pinMode(pins[n],INPUT); digitalWrite(pins[n],HIGH);}
    
 for(
n=0;n<8;n++)
   {
pinMode(p1[n],OUTPUT);pinMode(p2[n],OUTPUT);pinMo
de
(p3[n],OUTPUT);pinMode(p4[n],OUTPUT);
   
digitalWrite(p1[n],unpressed); digitalWrite(p2[n],unpressed);
    
digitalWrite(p3[n],unpressed);digitalWrite(p4[n],u
npressed
);} 
   
 
lcd.begin(20,4);
 
Serial.begin(115200);
 for(
n=0;n<1200;n++){record1[n]=all_unpressedrecord2[n]=all_unpressed;
                    
record3[n]=all_unpressedrecord4[n]=all_unpressed;}
}

void dispP1(){
   for(
n=0;n<8;n++){lcd.setCursor(n,1);lcd.print(bitRead(record1[current_slot],n));
                    
lcd.setCursor(n+8,1);lcd.print(bitRead(record3[current_slot],n));}}
void dispP2(){
   for(
n=0;n<8;n++){lcd.setCursor(n,2);lcd.print(bitRead(record2[current_slot],n));
                    
lcd.setCursor(n+8,2);lcd.print(bitRead(record4[current_slot],n));}}

void loop() {
  
time2=micros();
  if((
time2)>(time1+F)) {
    
time1=micros();
       
  if(
mode==1) {//time4=(micros()-time3);time3=micros();Serial.println(time4);
    
if(P1==1){for(n=0;n<8;n++)
      {
digitalWrite(p1[n],(bitRead(record1[frame_count],
n)));
       
digitalWrite(p3[n],(bitRead(record3[frame_count],n
)));}}
    if(
P2==1){for(n=0;n<8;n++)
      {
digitalWrite(p2[n],(bitRead(record2[frame_count],
n)));
       
digitalWrite(p4[n],(bitRead(record4[frame_count],n
)));}}
      if((
frame_count==loop_frame) && (repetition>0))
     {
repetition--;frame_count=-1;}
    
    if(
frame_count>1199){for(n=0;n<8;n++)
     {
digitalWrite(p1[n],unpressed); digitalWrite(p2[n],unpressed);
      
digitalWrite(p3[n],unpressed); digitalWrite(p4[n],unpressed);}
    
mode=-1;} 
     } 


   if(
mode==2) {
     if(
P1==1){for(n=0;n8;n++){bitWrite(record1[frame_count],n,digitalRead
(p1[n]));
                                   
bitWrite(record3[frame_count],n,digitalRead(p3[n])
);}}
     if(
P2==1){for(n=0;n8;n++){bitWrite(record2[frame_count],n,digitalRead
(p2[n]));
                                  
bitWrite(record4[frame_count],n,digitalRead(p4[n])
);}}
 if(
frame_count==0){
   if((
P1==1) && (P2==0) && (record1[0]==all_unpressed) && (record3[0]==all_unpressed)){frame_count=-1;} 
   if((
P1==0) && (P2==1) && (record2[0]==all_unpressed) && (record4[0]==all_unpressed)){frame_count=-1;} 
   if((
P1==1) && (P2==1) && (record1[0]==all_unpressed) && (record3[0]==all_unpressed) && 
       (
record2[0]==all_unpressed) && (record4[0]==all_unpressed)){frame_count=-1;} 
   
   
   
 }
 if(
frame_count>1199){mode=-1;}
}


  if(
mode==0){
     if(
P1==1){for(n=0;n8;n++){bitWrite(record1[current_slot],n,digitalRea
d
(p1[n]));
                                 
bitWrite(record3[current_slot],n,digitalRead(p3[n]
));}}
     if(
P2==1){for(n=0;n8;n++){bitWrite(record2[current_slot],n,digitalRea
d
(p2[n]));
                                
bitWrite(record4[current_slot],n,digitalRead(p4[n]
));}}

     
dispP2();dispP1();  
                     
     
current_slot++;delay(300);
      
     
dispP2();
     
dispP1(); 
      
mode=-1;}


  if (
digitalRead(pins[6])==1){P1=0;}
    if (
digitalRead(pins[8])==1){P2=0;}
    if (
digitalRead(pins[6])==0){P1=1;}
    if (
digitalRead(pins[8])==0){P2=1;}
    if(
digitalRead(pins[7])==&& digitalRead(pins[6])==&& digitalRead(pins[8])==1){P1=1;P2=1;}

   
button=0
   if(
digitalRead(pins[0])==0){button=5;}
   if(
digitalRead(pins[1])==0){button=7;}
   if(
digitalRead(pins[2])==0){button=4;}
   if(
digitalRead(pins[3])==0){button=8;}
   if(
digitalRead(pins[4])==0){button=2;}
   if(
digitalRead(pins[5])==0){button=6;}


  if (
button==4){
    
mode=-1;for(n=0;n<8;n++)
     {
digitalWrite(p1[n],unpressed); digitalWrite(p2[n],unpressed);
      
digitalWrite(p3[n],unpressed); digitalWrite(p4[n],unpressed);}
    if ((
cursor_position>0) && (last_button==0)){cursor_position--;}
    
//if ((cursor_position==0) &&  (last_button==0)){controller_used++;if(controller_
used>3){controller_used=1;}}
  }
 
 
  
//if(controller_used==1){P1=1;P2=0;}
  //if(controller_used==2){P1=0;P2=1;}
  //if(controller_used==3){P1=1;P2=1;}
  
  
if (button==6){
    
mode=-1;
    for(
n=0;n<8;n++)
     {
digitalWrite(p1[n],unpressed); digitalWrite(p2[n],unpressed);
      
digitalWrite(p3[n],unpressed); digitalWrite(p4[n],unpressed);}
    
    
//if((cursor_position==9) && (last_button==0)){
    //  if((P1==1)&&(p1[0]==22)){invert_controls=1;}
    //  if((P1==1) && (p1[0]==24)){invert_controls=2;}
    //  if(invert_controls==1) {p1[0]=24; p1[1]=22;}
    //  if(invert_controls==2) {p1[0]=22; p1[1]=24;}
    //  invert_controls=0;
      
    //  if((P2==1) && (p2[0]==23)){invert_controls=3;}
    //  if((P2==1) && (p2[0]==25)){invert_controls=4;}
    //  if(invert_controls==3) {p2[0]=25; p2[1]=23;}
    //  if(invert_controls==4) {p2[0]=23; p2[1]=25;}  
    
    // invert_controls=0;
    
    //}

    
   
if((cursor_position <19) && (last_button==0)){cursor_position++;}}


  if(
button==8){
    if((
cursor_position==0) && (last_button==0) && (current_slot<1199)){
          
current_slot++;mode=-1;
      
dispP2();dispP1();    
        }
   
   if((
cursor_position==1) && (current_slot<1199)){
     
delay(25);           current_slot++;mode=-1;
          
dispP2();dispP1(); 
        }
   
   if((
cursor_position==2) && (current_slot<1199)){
          
delay(5);
          
current_slot++;mode=-1;
         
// dispP2();dispP1(); 
        
}
   
   if((
cursor_position==3) && (last_button==0) && (current_slot<1199)){
     if(
P1==1) {record1[current_slot+1]=record1[current_slot]; record1[current_slot]=all_unpressed;
                
record3[current_slot+1]=record3[current_slot]; record3[current_slot]=all_unpressed;}
     if(
P2==1) {record2[current_slot+1]=record2[current_slot]; record2[current_slot]=all_unpressed;
                
record4[current_slot+1]=record4[current_slot]; record4[current_slot]=all_unpressed;}
                  
current_slot++;mode=-1;
     
dispP2();dispP1();}
   
   if((
cursor_position==4) && (last_button==0) && (current_slot<1199)){             
     if(
P1==1) {record1[current_slot+1]=record1[current_slot];
                 
record3[current_slot+1]=record3[current_slot];}     
     if(
P2==1)  {record2[current_slot+1]=record2[current_slot];
                 
record4[current_slot+1]=record4[current_slot];}
                 
current_slot++;mode=-1;
      
dispP2();dispP1(); }
   
   if((
cursor_position==5) && (last_button==0) && (current_slot<1199)){
     if(
P1==1){for(n=1198;n>(current_slot-1);n-- ){record1[n+1]=record1[n];record3[n+1]=record3[n];
}
                                           
record1[current_slot]=all_unpressed;record3[curren
t_slot
]=all_unpressed;}
     if(
P2==1){for(n=1198;n>(current_slot-1);n-- ){record2[n+1]=record2[n];record4[n+1]=record4[n];
}
                                           
record2[current_slot]=all_unpressed;record4[curren
t_slot
]=all_unpressed;}
      
current_slot++;mode=-1;
      
dispP2();dispP1();}
  
  if((
cursor_position==6) && (last_button==0)){
  if(
P1==1){for(n=1198;n>-1;n-- ){record1[n+1]=record1[n];record3[n+1]=record3[n];
}
                                           
record1[0]=all_unpressed;record3[0]=all_unpressed;
}
     if(
P2==1){for(n=1198;n>-1;n-- ){record2[n+1]=record2[n];record4[n+1]=record4[n];
}
                                           
record2[0]=all_unpressed;record4[0]=all_unpressed;
}
      
current_slot++;mode=-1;
      
dispP2();dispP1();}
  
    if(
cursor_position==16){F++;}

    if((
cursor_position==7) && (loop_frame<1199))
      {
delay(50);loop_frame++;}                   
 
    if((
cursor_position==8) && (loop_number<40) && (last_button==0))
      {
loop_number++;}
     
    if(
cursor_position==9){
      
unpressed=1;pressed=0;all_unpressed=255;
      for(
n=0;n<8;n++){
       
digitalWrite(p1[n],unpressed); digitalWrite(p2[n],unpressed);
       
digitalWrite(p3[n],unpressed); digitalWrite(p4[n],unpressed);} 

      for(
n=0;n<1200;n++){record1[n]=all_unpressedrecord2[n]=all_unpressed;
                          
record3[n]=all_unpressed;record4[n]=all_unpressed;
}}  
  
  }

                  
  if ((
button==2)){
    if ((
cursor_position==0) && (last_button==0) && (current_slot>0)){
     
current_slot--;mode=-1;
     
dispP2();dispP1();}

    if ((
cursor_position==1) && (current_slot>0)){
     
delay(25); current_slot--;mode=-1;
     
dispP2();dispP1();}

    if ((
cursor_position==2) && (current_slot>0)){
     
delay(5); current_slot--;mode=-1;
     
//dispP2();dispP1();
   
}    
    
    if ((
cursor_position==3) && (current_slot>0) && (last_button==0)){
      if(
P1==1) {record1[current_slot-1]=record1[current_slot]; record1[current_slot]=all_unpressed;
                 
record3[current_slot-1]=record3[current_slot]; record3[current_slot]=all_unpressed;}
      if(
P2==1)  {record2[current_slot-1]=record2[current_slot]; record2[current_slot]=all_unpressed;
                  
record4[current_slot-1]=record4[current_slot]; record4[current_slot]=all_unpressed;}
            
current_slot--;mode=-1;
     
dispP2();
     
dispP1();}
    
    if ((
cursor_position==4) && (current_slot>0) && (last_button==0)){ 
      if (
P1==1) {record1[current_slot-1]=record1[current_slot];
                                          
record3[current_slot-1]=record3[current_slot];}
      if (
P2==1) {record2[current_slot-1]=record2[current_slot];
                                          
record4[current_slot-1]=record4[current_slot];}
     
current_slot--;mode=-1;
     
dispP2();
     
dispP1();}
  
  if ((
cursor_position==5) && (current_slot>0) && (last_button==0)){
    if (
P1==1) {for(n=current_slot;n<1199;n++){record1[n-1]=record1[n];record3[n-1]=record3[n];}
       
record1[1199]=all_unpressed;record3[1199]=all_unpr
essed
;}
    if (
P2==1) {for(n=current_slot;n<1199;n++){record2[n-1]=record2[n];record4[n-1]=record4[n];}
       
record2[1199]=all_unpressed;record4[1199]=all_unpr
essed
;}
     
current_slot--;mode=-1;
     
dispP2();
     
dispP1();  
 }    
                  
                
                
  if((
cursor_position==6)&& (current_slot>0) && (last_button==0)){
                if (
P1==1) {for(n=1;n<1199;n++){record1[n-1]=record1[n];record3[n-1]=record3[n];}
       
record1[1199]=all_unpressed;record3[1199]=all_unpr
essed
;}
    if (
P2==1) {for(n=1;n<1199;n++){record2[n-1]=record2[n];record4[n-1]=record4[n];}
       
record2[1199]=all_unpressed;record4[1199]=all_unpr
essed
;}
     
current_slot--;mode=-1;
     
dispP2();
     
dispP1(); }
                
                
  if(
cursor_position==16){F--;}
  
  if((
cursor_position==7) && (loop_frame>0))
     {
delay(50);loop_frame--;}
  
  if((
cursor_position==8) && (loop_number>0) && (last_button==0))
    {
loop_number--;}

  if(
cursor_position==9){
      
unpressed=0;pressed=1;all_unpressed=0;
      for(
n=0;n<8;n++){
       
digitalWrite(p1[n],unpressed); digitalWrite(p2[n],unpressed);
       
digitalWrite(p3[n],unpressed); digitalWrite(p4[n],unpressed);} 

      for(
n=0;n<1200;n++){record1[n]=all_unpressedrecord2[n]=all_unpressed;
                         
record3[n]=all_unpressedrecord4[n]=all_unpressed;}}

  }

  if(
button==5){
    if((
cursor_position==0) && (last_button==0))
      {
mode=0;}
    
    if((
cursor_position==1) && (last_button==0))
      {
repetition=0;frame_count=-1;mode=1;}
    
    if((
cursor_position==2) && (last_button==0)){
        if(
P1==1)
          {for(
n=0;n1200;n++){record1[n]=all_unpressed;record3[n]=all_
unpressed
;}frame_count=-1;mode=2;}
        if(
P2==1)
          {for(
n=0;n1200;n++){record2[n]=all_unpressed;record4[n]=all_
unpressed
;}frame_count=-1;mode=2;}}

    if((
cursor_position==3) && (last_button==0))
      {
frame_count=-1;mode=1;}
    
    if((
cursor_position==4) && (last_button==0))
      {
frame_count=-1;mode=1;}
    
    if((
cursor_position==5) && (last_button==0))
      {
frame_count=-1;mode=1;}

    if((
cursor_position==6) && (last_button==0))
      {
frame_count=-1;mode=1;}

    if((
cursor_position==7) && (last_button==0))
      {
repetition=loop_number;frame_count=-1;mode=3;}

    if((
cursor_position==8) && (last_button==0))
      {
repetition=loop_number;frame_count=-1;mode=3;}

    if(
cursor_position==9)
      {if(
P1==1){for(n=0;n1200;n++){record1[n]=all_unpressed;record3[n]=all_
unpressed
;}frame_count=-1;cursor_position=0;current_slot=0;}
       if(
P2==1){for(n=0;n1200;n++){record2[n]=all_unpressed;record4[n]=all_
unpressed
;}frame_count=-1;cursor_position=0;current_slot=0;}
       
loop_frame=148;loop_number=3;lag=0;lcd.clear();}


  }

  


  
//CUT HERE TO SPEED UP LCD
     
lcd.setCursor(0,0);lcd.print(current_slot);
     
lcd.setCursor(4,0);lcd.print(cursor_position);
     
lcd.setCursor(7,0);lcd.print(loop_number); 
     
lcd.setCursor(10,0);lcd.print(loop_frame);
     
lcd.setCursor(14,0);lcd.print(P1);
     
lcd.setCursor(15,0);lcd.print(P2); 
     if(
cursor_position==6){lcd.setCursor(11,1);lcd.print(F);}
     if(
cursor_position>2){lcd.setCursor(14,0);lcd.print("     ");}
     
     
     
lcd.setCursor(0,3);lcd.print(button);
     
lcd.setCursor(2,3);lcd.print(P1);
     
lcd.setCursor(4,3);lcd.print(P2);
     
     
time2=micros();
//CUT HERE TO SPEED UP LCD     
     
     
     
frame_count++;
     
last_button=button;

  }
  }
noodalls
Moderator
Joined: May 2003
Posts: 2335
From: Australia
PSN: noodalls
#50 “Quote” Edit Post
Managed to add support for SD cards today. Basically, you can save your sequence to an SD card, copy it to PC, edit it there and reimport it to the programmable stick.

Still messy at the moment, but as proof of concept, it seems solid.
noodalls
Moderator
Joined: May 2003
Posts: 2335
From: Australia
PSN: noodalls
#51 “Quote” Edit Post
Awesome. Spent about an hour playing with a combo for someone, then realised I wasn't hooked up to capture equipment, so could only record it with normal camera. Then remembered the SD card stuff that I'd programmed. Reminded myself how to use it, saved the combo to SD card and now can capture it at any time in the future.
|Galen|
In iWS1 I trust!
Joined: Jan 2003
Posts: 9242
PSN: Galen-SDT
XBL: Galen SDT
#52 “Quote” Edit Post
Originally posted by noodalls
Awesome. Spent about an hour playing with a combo for someone, then realised I wasn't hooked up to capture equipment, so could only record it with normal camera. Then remembered the SD card stuff that I'd programmed. Reminded myself how to use it, saved the combo to SD card and now can capture it at any time in the future.


Much love Noodalls! I gotta figure out all the in's and out's of Nina's 4,3,d+4,3 as a TA and how to maximize scaling resets. I think I'm going to try and make a stick now. That way I don't have to pester you to find all the glorious goodness that you always find!

Again, thanks very much for testing for me though!


+++Update
I just read all the stuff that needs done and I'm not savvy enough to do anything like that! My hat is off to you Noodalls.
Signature In iWS1 I trust!
Battle Jitni- @Galen: (imagine that's a middle finger instead)
Mr. Taxi- "Galen, I don't consider you an Anna player. I have this theory that all Anna players like penis. So until you S a D you aren't an Anna player"
Dilly a couple months after he found out he was expecting- "Galen, Sith, in 9 months I'm challenging you both to diaper matches. Loser buys diapers for the winner. "
Claka
UNTOLD!!!!!!!
Joined: Jan 2000
Posts: 2154
#53 “Quote” Edit Post
Remember me?

I'm currently using a Xim3 + usb cable + glovepie
it's alot more 'retail' than than going down custom route that noodalls (i myself in the past) have taken. it also gives you alot of options in normal gaming.

glovepie makes it really easy to script inputs. EG.

if key.p = true then
; start with reset
key.s and key.3 =true
wait 20ms
key.s and key.3 = false
wait 500ms
key.Right=true
wait 16.67ms
key.right = false
wait 16.67ms
key.Right=true
wait 16.67ms
;key.Righ = false
key.4 = true
wait 16.67ms
key.4 and key.Right = false
wait 720ms
key.1 = true
wait 16.67ms
key.1 = false
wait 100ms
;Tag
key.5 = true
wait 17ms
key.5 = false
wait 830ms
key.down = true
wait 16.67ms
key.down and key.Right= true
wait 16.67ms
key.down = false
wait 16.67ms
key.3 = true
wait 16.67ms
key.3 and key.Right= false

wait 400ms
key.Right=true
wait 16.67ms
key.right = false
wait 16.67ms
key.Right=true
wait 16.67ms
key.4 = true
wait 16.67ms
key.4 and key.Right = false

wait 800ms
key.4 = true
wait 16.67ms
key.4 = false



else
endif
Signature "When a comically fat woman can dress up as Chun Li, but you're not allowed to slap the back of her head and call her a natural disaster, you have to wonder what's wrong with this country... and my answer to that is always: nothing you can't put right with a bottle of Jim Beam and a set of wheels."
noodalls
Moderator
Joined: May 2003
Posts: 2335
From: Australia
PSN: noodalls
Claka
UNTOLD!!!!!!!
Joined: Jan 2000
Posts: 2154
#55 “Quote” Edit Post
Noodalls, you ever thought of using a Raspberry pi with an I2C jumper board? you could fire your pins from any number of languages. you could have keyboard macros and everything.
Signature "When a comically fat woman can dress up as Chun Li, but you're not allowed to slap the back of her head and call her a natural disaster, you have to wonder what's wrong with this country... and my answer to that is always: nothing you can't put right with a bottle of Jim Beam and a set of wheels."
noodalls
Moderator
Joined: May 2003
Posts: 2335
From: Australia
PSN: noodalls
#56 “Quote” Edit Post
I bought a Pi, but just haven't had time to get into it. I think the simplicity of the arduino is what got me in in the first place. The PCDuino is similarly attractive, but again, not had a chance to buy or play with it.
|Galen|
In iWS1 I trust!
Joined: Jan 2003
Posts: 9242
PSN: Galen-SDT
XBL: Galen SDT
#57 “Quote” Edit Post
I'm not. My actual city /town is Menifee, Ca
Signature In iWS1 I trust!
Battle Jitni- @Galen: (imagine that's a middle finger instead)
Mr. Taxi- "Galen, I don't consider you an Anna player. I have this theory that all Anna players like penis. So until you S a D you aren't an Anna player"
Dilly a couple months after he found out he was expecting- "Galen, Sith, in 9 months I'm challenging you both to diaper matches. Loser buys diapers for the winner. "

 All times are GMT. The time now is 14:30

Page Splits <123
Moderator Tools
Forum Jump